Skip to content

Commit 2a227f0

Browse files
committed
Updates for TYPO3 v13
1 parent 0f8e439 commit 2a227f0

18 files changed

+46
-31
lines changed

Classes/Backend/GetButtonsHook.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
use TYPO3\CMS\Backend\Template\Components\Buttons\InputButton;
77
use TYPO3\CMS\Backend\Template\Components\ModifyButtonBarEvent;
8-
use TYPO3\CMS\Core\Imaging\Icon;
98
use TYPO3\CMS\Core\Imaging\IconFactory;
9+
use TYPO3\CMS\Core\Imaging\IconSize;
1010
use TYPO3\CMS\Core\Localization\LanguageService;
1111
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
1212

@@ -40,7 +40,7 @@ public function __invoke(ModifyButtonBarEvent $event): void {
4040
$saveAndClose = new InputButton();
4141

4242
$saveAndClose->setForm($button->getForm());
43-
$saveAndClose->setIcon($this->iconFactory->getIcon('actions-document-save-close', Icon::SIZE_SMALL));
43+
$saveAndClose->setIcon($this->iconFactory->getIcon('actions-document-save-close', IconSize::SMALL));
4444
$saveAndClose->setName('_saveandclosedok');
4545
$saveAndClose->setTitle($this->languageService->sL(
4646
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:rm.saveCloseDoc'

Classes/Console/Command/Database/BaseDatabaseCommand.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ protected function getIgnoredTables(): array {
130130
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
131131
$connection = $connectionPool->getConnectionByName('Default');
132132
// Get all tables (even the filtered tables)
133-
$connection->getConfiguration()->setSchemaAssetsFilter(null);
133+
$connection->getConfiguration()->setSchemaAssetsFilter(function (): bool {
134+
return true;
135+
});
134136
$schemaManager = $connection->createSchemaManager();
135137
$tables = $schemaManager->listTableNames();
136138

Classes/Console/Command/PostComposerCommand.php

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ protected function hasValidDatabaseConnection(): bool {
7272
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
7373
$connection = $connectionPool->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME);
7474
try {
75-
$connection->connect();
7675
return count($connection->createSchemaManager()->listTableNames()) > 0;
7776
} catch (ConnectionException $e) {
7877
return false;

Classes/Database/ForceMyISAM.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public function getCreateTableStatementArray(string $dumpContent): array {
3838
$platform = $connectionPool->getConnectionByName('Default')->getDatabasePlatform();
3939

4040
$statements = array_map(function(string $statement) use ($platform) {
41-
$parser = GeneralUtility::makeInstance(Parser::class, $statement);
42-
$tables = $parser->parse();
41+
$parser = GeneralUtility::makeInstance(Parser::class);
42+
$tables = $parser->parse($statement);
4343
$table = $tables[0];
4444
$forceMyISAM = in_array($table->getName(), self::$MyISAMTables);
4545
foreach (self::$tablePrefixes as $tablePrefix) {

Classes/Form/Element/HotspotEditorElement.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616

1717
class HotspotEditorElement extends AbstractNode {
1818

19-
/**
20-
* @return array As defined in initializeResultArray() of AbstractNode
21-
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint
22-
*/
23-
public function render() {
19+
public function render(): array {
2420
$html = $this->getHtml();
2521

2622
$result = $this->initializeResultArray();
@@ -62,7 +58,7 @@ protected function getHtml(): string {
6258
}
6359

6460
$view = GeneralUtility::makeInstance(StandaloneSmartyView::class);
65-
$view->setTemplateRootPaths(['EXT:vierwd_base/Resources/Private/Templates/']);
61+
$view->getRenderingContext()->getTemplatePaths()->setTemplateRootPaths(['EXT:vierwd_base/Resources/Private/Templates/']);
6662

6763
$view->assignMultiple([
6864
'cropVariants' => $cropVariants,

Classes/Hooks/ContentElements.php

+1
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ static public function addFCEs(string $extensionKey, bool $isLocalConf = false):
300300

301301
if ($pageTS) {
302302
// FOR USE IN ext_localconf.php FILES
303+
// @phpstan-ignore-next-line addPageTSConfig is deprecated. This needs to be fixed before TYPO3 v13. Use ModifyLoadedPageTsConfigEvent instead
303304
ExtensionManagementUtility::addPageTSConfig($pageTS);
304305
}
305306
}

Classes/Resource/CacheBuster.php

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public function __invoke(GeneratePublicUrlForResourceEvent $event): void {
1616
$publicUrl = $event->getPublicUrl();
1717

1818
if ($storage->isPublic() && $resource instanceof Resource\FileInterface) {
19+
assert($resource->getIdentifier() !== '');
1920
$publicUrl = $driver->getPublicUrl($resource->getIdentifier());
2021
if ($resource instanceof Resource\ProcessedFile || $resource instanceof Resource\FileReference) {
2122
$publicUrl .= '?_=' . $resource->getOriginalFile()->getModificationTime();

Classes/Resource/LocalDriver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class LocalDriver extends \TYPO3\CMS\Core\Resource\Driver\LocalDriver {
88
/**
99
* {@inheritdoc}
1010
*/
11-
public function sanitizeFileName($fileName, $charset = 'utf-8') {
11+
public function sanitizeFileName(string $fileName, string $charset = 'utf-8'): string {
1212
$fileName = parent::sanitizeFileName($fileName, $charset);
1313

1414
$pathinfo = pathinfo($fileName);

Classes/Routing/Aspect/AutomaticSlugPatternMapper.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Vierwd\VierwdBase\Routing\Aspect;
55

6+
use Doctrine\DBAL\ParameterType;
67
use TYPO3\CMS\Core\Charset\CharsetConverter;
78
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
89
use TYPO3\CMS\Core\Routing\Aspect\PersistedPatternMapper;
@@ -96,7 +97,7 @@ protected function createRouteFieldConstraints(QueryBuilder $queryBuilder, array
9697

9798
$constraints = [];
9899
foreach ($this->settings['matchFields'] as $fieldName) {
99-
$constraints[] = $queryBuilder->expr()->eq($fieldName, $queryBuilder->createNamedParameter($values[$fieldName], \PDO::PARAM_STR));
100+
$constraints[] = $queryBuilder->expr()->eq($fieldName, $queryBuilder->createNamedParameter($values[$fieldName], ParameterType::STRING));
100101
}
101102

102103
return $constraints;

Classes/Utility/ImageUtility.php

+17-3
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,25 @@ class ImageUtility {
1919
* @return array{'x': int, 'y': int, 'width': int, 'height': int}
2020
*/
2121
public static function getCrop(FileInterface $image, string $cropAreaName = 'default'): array {
22+
$width = $image->getProperty('width');
23+
$height = $image->getProperty('height');
24+
assert(is_int($width));
25+
assert(is_int($height));
26+
2227
$emptyCrop = [
2328
'x' => 0,
2429
'y' => 0,
25-
'width' => (int)$image->getProperty('width'),
26-
'height' => (int)$image->getProperty('height'),
30+
'width' => $width,
31+
'height' => $height,
2732
];
2833

2934
$crop = $image->getProperty('crop');
3035
if (!$crop) {
3136
return $emptyCrop;
3237
}
3338

39+
assert(is_string($crop));
40+
3441
$cropVariantCollection = CropVariantCollection::create($crop);
3542
$cropArea = $cropVariantCollection->getCropArea($cropAreaName);
3643
if ($cropArea->isEmpty()) {
@@ -56,7 +63,13 @@ public static function convertCropForProcessing(FileInterface $image, ?array $cr
5663
if ($cropValues === null) {
5764
return null;
5865
}
59-
if ($cropValues['x'] === 0 && $cropValues['y'] === 0 && $cropValues['width'] === (int)$image->getProperty('width') && $cropValues['height'] === (int)$image->getProperty('height')) {
66+
67+
$width = $image->getProperty('width');
68+
$height = $image->getProperty('height');
69+
assert(is_int($width));
70+
assert(is_int($height));
71+
72+
if ($cropValues['x'] === 0 && $cropValues['y'] === 0 && $cropValues['width'] === $width && $cropValues['height'] === $height) {
6073
// If the crop is the full image, it's faster to use "no crop".
6174
return null;
6275
}
@@ -99,6 +112,7 @@ public static function adjustSizeForCrop(array $size, array $crop): array {
99112
public static function getHotspot(FileInterface $image): array {
100113
$hotspot = $image->getProperty('hotspot');
101114
if ($hotspot) {
115+
assert(is_string($hotspot));
102116
$hotspot = json_decode($hotspot, true);
103117
}
104118

Classes/Utility/LinkUtility.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
77
use TYPO3\CMS\Core\LinkHandling\LinkService;
8+
use TYPO3\CMS\Core\LinkHandling\TypoLinkCodecService;
89
use TYPO3\CMS\Core\Utility\GeneralUtility;
910
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
10-
use TYPO3\CMS\Frontend\Service\TypoLinkCodecService;
1111

1212
use function Safe\parse_url;
1313

Classes/Utility/YouTubeUtility.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Vierwd\VierwdBase\Utility;
55

66
use TYPO3\CMS\Core\Core\Environment;
7-
use TYPO3\CMS\Core\Resource\DuplicationBehavior;
7+
use TYPO3\CMS\Core\Resource\Enum\DuplicationBehavior;
88
use TYPO3\CMS\Core\Resource\File;
99
use TYPO3\CMS\Core\Resource\FileInterface;
1010
use TYPO3\CMS\Core\Resource\ProcessedFile;

Classes/ViewHelpers/SvgViewHelper.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
use TYPO3\CMS\Core\Utility\GeneralUtility;
77
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
8-
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
98
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
10-
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
119

1210
use Vierwd\VierwdBase\Frontend\ContentObject\ScalableVectorGraphicsContentObject;
1311

@@ -21,8 +19,6 @@
2119
*/
2220
class SvgViewHelper extends AbstractViewHelper {
2321

24-
use CompileWithRenderStatic;
25-
2622
/**
2723
* @phpcsSuppress SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint
2824
* @var bool
@@ -43,10 +39,10 @@ public function initializeArguments(): void {
4339
*
4440
* {@inheritdoc}
4541
*/
46-
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
42+
public function render() {
4743
$cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
4844
$svgObject = GeneralUtility::makeInstance(ScalableVectorGraphicsContentObject::class, $cObj);
49-
return $svgObject->render($arguments);
45+
return $svgObject->render($this->arguments);
5046
}
5147

5248
}

Classes/XClass/Core/Resource/StorageRepository.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class StorageRepository extends \TYPO3\CMS\Core\Resource\StorageRepository {
1414
/**
1515
* {@inheritdoc}
1616
*/
17-
protected function testCaseSensitivity($absolutePath) {
17+
protected function testCaseSensitivity($absolutePath): bool {
1818
return true;
1919
}
2020

Tests/Unit/Backend/GetButtonsHookTest.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ public function setUp(): void {
2929

3030
$iconMock = $this->prophesize(Icon::class);
3131

32-
$iconFactoryMock = $this->prophesize(IconFactory::class);
33-
$iconFactoryMock->getIcon(Argument::any(), Argument::any())->willReturn($iconMock->reveal());
32+
$iconFactoryMock = $this->createMock(IconFactory::class);
33+
$iconFactoryMock->method('getIcon')->willReturn($iconMock->reveal());
34+
// $iconFactoryMock->getIcon(Argument::any(), Argument::any())->willReturn($iconMock->reveal());
3435
$this->iconMock = $iconMock->reveal();
3536

3637
$languageServiceMock = $this->prophesize(LanguageService::class);
@@ -39,11 +40,12 @@ public function setUp(): void {
3940
$languageServiceFactoryMock = $this->prophesize(LanguageServiceFactory::class);
4041
$languageServiceFactoryMock->createFromUserPreferences(Argument::any())->willReturn($languageServiceMock->reveal());
4142

42-
$this->subject = new GetButtonsHook($iconFactoryMock->reveal(), $languageServiceFactoryMock->reveal());
43+
$this->subject = new GetButtonsHook($iconFactoryMock, $languageServiceFactoryMock->reveal());
4344
}
4445

4546
public function testAdjustSaveAndCloseWithoutLeftButtons(): void {
4647
$arrayWithoutLeftButtons = ['right' => 'ignore'];
48+
// @phpstan-ignore-next-line
4749
$event = new ModifyButtonBarEvent($arrayWithoutLeftButtons, $this->prophesize(ButtonBar::class)->reveal());
4850
call_user_func($this->subject, $event);
4951
self::assertEquals($arrayWithoutLeftButtons, $event->getButtons());
@@ -57,6 +59,7 @@ public function testAdjustSaveAndCloseWithoutSavedOkButton(): void {
5759
'group' => [$saveButtonMock->reveal()],
5860
],
5961
];
62+
// @phpstan-ignore-next-line
6063
$event = new ModifyButtonBarEvent($buttons, $this->prophesize(ButtonBar::class)->reveal());
6164
call_user_func($this->subject, $event);
6265
self::assertEquals($buttons, $event->getButtons());

Tests/Unit/Resource/FilterFilesTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testFilterFilesCallback(bool|int $expected, string $itemName, st
2121
self::assertEquals($expected, FilterFiles::filterFilesCallback($itemName, $itemIdentifier, dirname($itemIdentifier), [], $driverInstance));
2222
}
2323

24-
public function getSanitizeFileNameTestData(): array {
24+
public static function getSanitizeFileNameTestData(): array {
2525
return [
2626
[-1, '.svn', '/.svn/'],
2727
[-1, '.git', '/.git/'],

Tests/Unit/Resource/LocalDriverTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function testSanitizeFileName(string $expected, string $fileName): void {
2222
self::assertEquals($expected, $subject->sanitizeFileName($fileName));
2323
}
2424

25-
public function getSanitizeFileNameTestData(): array {
25+
public static function getSanitizeFileNameTestData(): array {
2626
return [
2727
['Test.txt', 'Test.txt'],
2828
['test.txt', 'test.txt'],

composer.json

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
}],
1919
"require": {
2020
"php": "^8.2.0",
21+
"helhum/typo3-console": "^8.0.0",
2122
"linkorb/jsmin-php": "^1.0",
2223
"masterminds/html5": "^2.6",
2324
"thecodingmachine/safe": "^2.5",
@@ -39,6 +40,7 @@
3940
"phpunit/phpunit": "^11.0",
4041
"saschaegerer/phpstan-typo3": "^1.1.0",
4142
"typo3/cms-core": "^13.4",
43+
"typo3/cms-extensionmanager": "^13.4",
4244
"typo3/cms-fluid": "^13.4",
4345
"typo3/cms-frontend": "^13.4",
4446
"typo3/cms-impexp": "^13.4",

0 commit comments

Comments
 (0)