Files
frommeandClaude Opus 5.5 ecd5ea66c5 refactor: type declarations via Rector
rector.php gets the typeDeclarations set: return types (void, array,
unions) where the code proves them, typed closures and arrow functions,
typed properties from constructors and assignments in the DTOs.

Skipped: rules that infer scalar or array parameter types from call
sites or docblocks, and the removal of casts the docblocks call
redundant. Values from the database, form input and the import feeds
arrive as strings and would throw instead of being converted (e.g. the
(int) cast of the newsletter list ids stays).

Checked locally: cache warmup, frontend crawl (~1,900 URLs), the
backchannel APIs and the newsletter form validation behave as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 11:21:12 +01:00

66 lines
3.2 KiB
PHP

<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\Cast\RecastingRemovalRector;
use Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ScalarParamTypeByMethodCallTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\StrictArrayParamDimFetchRector;
use Rector\TypeDeclaration\Rector\FuncCall\AddArrayFunctionClosureParamTypeRector;
use Rector\TypeDeclaration\Rector\FuncCall\AddArrowFunctionParamArrayWhereDimFetchRector;
use Rector\TypeDeclaration\Rector\FunctionLike\AddClosureParamTypeForArrayMapRector;
use Rector\ValueObject\PhpVersion;
use Ssch\TYPO3Rector\CodeQuality\General\ConvertImplicitVariablesToExplicitGlobalsRector;
use Ssch\TYPO3Rector\CodeQuality\General\ExtEmConfRector;
use Ssch\TYPO3Rector\CodeQuality\General\RemoveTypo3VersionChecksRector;
use Ssch\TYPO3Rector\Configuration\Typo3Option;
use Ssch\TYPO3Rector\Set\Typo3LevelSetList;
use Ssch\TYPO3Rector\Set\Typo3SetList;
use Ssch\TYPO3Rector\TYPO313\v4\MigratePluginContentElementAndPluginSubtypesRector;
use Ssch\TYPO3Rector\TYPO313\v4\MigratePluginContentElementAndPluginSubtypesSwapArgsRector;
use Ssch\TYPO3Rector\TYPO313\v4\MigratePluginContentElementAndPluginSubtypesTCARector;
return RectorConfig::configure()
->withPaths([
__DIR__ . '/packages',
])
->withSkip([
__DIR__ . '/packages/*/Resources/Private/Assets/*',
// Plugins stay list_type plugins until the TYPO3 14 step, which migrates tt_content
MigratePluginContentElementAndPluginSubtypesRector::class,
MigratePluginContentElementAndPluginSubtypesSwapArgsRector::class,
MigratePluginContentElementAndPluginSubtypesTCARector::class,
// Scalar/array parameter types inferred from call sites or docblocks: values from the database, form
// input and the import feeds arrive as strings and would throw instead of being converted
RecastingRemovalRector::class,
AddMethodCallBasedStrictParamTypeRector::class,
ScalarParamTypeByMethodCallTypeRector::class,
StrictArrayParamDimFetchRector::class,
AddArrayFunctionClosureParamTypeRector::class,
AddArrowFunctionParamArrayWhereDimFetchRector::class,
AddClosureParamTypeForArrayMapRector::class,
])
->withPhpVersion(PhpVersion::PHP_85)
->withPhpSets(php85: true)
->withPreparedSets(deadCode: true, codeQuality: true, typeDeclarations: true)
->withSets([
Typo3SetList::GENERAL,
Typo3LevelSetList::UP_TO_TYPO3_13,
])
->withPHPStanConfigs([Typo3Option::PHPSTAN_FOR_RECTOR_PATH])
->withImportNames(true, true, false, true)
->withRules([
ConvertImplicitVariablesToExplicitGlobalsRector::class,
ExplicitNullableParamTypeRector::class,
])
->withConfiguredRule(ExtEmConfRector::class, [
ExtEmConfRector::PHP_VERSION_CONSTRAINT => '8.5.0-8.5.99',
ExtEmConfRector::TYPO3_VERSION_CONSTRAINT => '13.4.0-13.4.99',
ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [],
])
->withConfiguredRule(RemoveTypo3VersionChecksRector::class, [
RemoveTypo3VersionChecksRector::TARGET_VERSION => 13,
]);