Updated Rector to commit 12fa9407f734c847cb7739bd435ec42bc66a8f1c

12fa9407f7 [DeadCode] Skip @return static on return self when class is not final or in trait on RemoveUselessReturnTagRector (#2282)
This commit is contained in:
Tomas Votruba 2022-05-11 05:14:30 +00:00
parent 6feaa9edb7
commit 7e928f8b96
23 changed files with 357 additions and 549 deletions

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\NodeTypeResolver\TypeComparator; namespace Rector\NodeTypeResolver\TypeComparator;
use PhpParser\Node; use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode; use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode; use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\ArrayType; use PHPStan\Type\ArrayType;
@ -21,6 +22,7 @@ use PHPStan\Type\Type;
use PHPStan\Type\TypeTraverser; use PHPStan\Type\TypeTraverser;
use PHPStan\Type\UnionType; use PHPStan\Type\UnionType;
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory; use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
use Rector\NodeTypeResolver\PHPStan\TypeHasher; use Rector\NodeTypeResolver\PHPStan\TypeHasher;
use Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer; use Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer;
@ -64,7 +66,12 @@ final class TypeComparator
* @var \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer * @var \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer
*/ */
private $unionTypeAnalyzer; private $unionTypeAnalyzer;
public function __construct(\Rector\NodeTypeResolver\PHPStan\TypeHasher $typeHasher, \Rector\TypeDeclaration\TypeNormalizer $typeNormalizer, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\NodeTypeResolver\TypeComparator\ArrayTypeComparator $arrayTypeComparator, \Rector\NodeTypeResolver\TypeComparator\ScalarTypeComparator $scalarTypeComparator, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer $unionTypeAnalyzer) /**
* @readonly
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
*/
private $betterNodeFinder;
public function __construct(\Rector\NodeTypeResolver\PHPStan\TypeHasher $typeHasher, \Rector\TypeDeclaration\TypeNormalizer $typeNormalizer, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\NodeTypeResolver\TypeComparator\ArrayTypeComparator $arrayTypeComparator, \Rector\NodeTypeResolver\TypeComparator\ScalarTypeComparator $scalarTypeComparator, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer $unionTypeAnalyzer, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder)
{ {
$this->typeHasher = $typeHasher; $this->typeHasher = $typeHasher;
$this->typeNormalizer = $typeNormalizer; $this->typeNormalizer = $typeNormalizer;
@ -73,6 +80,7 @@ final class TypeComparator
$this->scalarTypeComparator = $scalarTypeComparator; $this->scalarTypeComparator = $scalarTypeComparator;
$this->typeFactory = $typeFactory; $this->typeFactory = $typeFactory;
$this->unionTypeAnalyzer = $unionTypeAnalyzer; $this->unionTypeAnalyzer = $unionTypeAnalyzer;
$this->betterNodeFinder = $betterNodeFinder;
} }
public function areTypesEqual(\PHPStan\Type\Type $firstType, \PHPStan\Type\Type $secondType) : bool public function areTypesEqual(\PHPStan\Type\Type $firstType, \PHPStan\Type\Type $secondType) : bool
{ {
@ -117,7 +125,7 @@ final class TypeComparator
if ($this->areTypesSameWithLiteralTypeInPhpDoc($areDifferentScalarTypes, $phpStanDocType, $phpParserNodeType)) { if ($this->areTypesSameWithLiteralTypeInPhpDoc($areDifferentScalarTypes, $phpStanDocType, $phpParserNodeType)) {
return \false; return \false;
} }
return $this->isThisTypeInFinalClass($phpStanDocType, $phpParserNodeType); return $this->isThisTypeInFinalClass($phpStanDocType, $phpParserNodeType, $phpParserNode);
} }
public function isSubtype(\PHPStan\Type\Type $checkedType, \PHPStan\Type\Type $mainType) : bool public function isSubtype(\PHPStan\Type\Type $checkedType, \PHPStan\Type\Type $mainType) : bool
{ {
@ -159,15 +167,15 @@ final class TypeComparator
} }
private function areAliasedObjectMatchingFqnObject(\PHPStan\Type\Type $firstType, \PHPStan\Type\Type $secondType) : bool private function areAliasedObjectMatchingFqnObject(\PHPStan\Type\Type $firstType, \PHPStan\Type\Type $secondType) : bool
{ {
if ($firstType instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType && $secondType instanceof \PHPStan\Type\ObjectType && $firstType->getFullyQualifiedName() === $secondType->getClassName()) { if ($firstType instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType && $secondType instanceof \PHPStan\Type\ObjectType) {
return \true; return $firstType->getFullyQualifiedName() === $secondType->getClassName();
}
if (!$secondType instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType) {
return \false;
} }
if (!$firstType instanceof \PHPStan\Type\ObjectType) { if (!$firstType instanceof \PHPStan\Type\ObjectType) {
return \false; return \false;
} }
if (!$secondType instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType) {
return \false;
}
return $secondType->getFullyQualifiedName() === $firstType->getClassName(); return $secondType->getFullyQualifiedName() === $firstType->getClassName();
} }
/** /**
@ -197,15 +205,16 @@ final class TypeComparator
} }
private function isMutualObjectSubtypes(\PHPStan\Type\Type $firstArrayItemType, \PHPStan\Type\Type $secondArrayItemType) : bool private function isMutualObjectSubtypes(\PHPStan\Type\Type $firstArrayItemType, \PHPStan\Type\Type $secondArrayItemType) : bool
{ {
if ($firstArrayItemType instanceof \PHPStan\Type\ObjectType && $secondArrayItemType instanceof \PHPStan\Type\ObjectType) { if (!$firstArrayItemType instanceof \PHPStan\Type\ObjectType) {
if ($firstArrayItemType->isSuperTypeOf($secondArrayItemType)->yes()) { return \false;
return \true;
}
if ($secondArrayItemType->isSuperTypeOf($firstArrayItemType)->yes()) {
return \true;
}
} }
return \false; if (!$secondArrayItemType instanceof \PHPStan\Type\ObjectType) {
return \false;
}
if ($firstArrayItemType->isSuperTypeOf($secondArrayItemType)->yes()) {
return \true;
}
return $secondArrayItemType->isSuperTypeOf($firstArrayItemType)->yes();
} }
private function normalizeSingleUnionType(\PHPStan\Type\Type $type) : \PHPStan\Type\Type private function normalizeSingleUnionType(\PHPStan\Type\Type $type) : \PHPStan\Type\Type
{ {
@ -226,10 +235,7 @@ final class TypeComparator
if (!$secondType instanceof \PHPStan\Type\ArrayType) { if (!$secondType instanceof \PHPStan\Type\ArrayType) {
return \false; return \false;
} }
if ($firstType instanceof \PHPStan\Type\Constant\ConstantArrayType) { if ($firstType instanceof \PHPStan\Type\Constant\ConstantArrayType || $secondType instanceof \PHPStan\Type\Constant\ConstantArrayType) {
return \false;
}
if ($secondType instanceof \PHPStan\Type\Constant\ConstantArrayType) {
return \false; return \false;
} }
$firstKeyType = $this->normalizeSingleUnionType($firstType->getKeyType()); $firstKeyType = $this->normalizeSingleUnionType($firstType->getKeyType());
@ -265,7 +271,7 @@ final class TypeComparator
{ {
return $areDifferentScalarTypes && $phpStanDocType instanceof \PHPStan\Type\ConstantScalarType && $phpParserNodeType->isSuperTypeOf($phpStanDocType)->yes(); return $areDifferentScalarTypes && $phpStanDocType instanceof \PHPStan\Type\ConstantScalarType && $phpParserNodeType->isSuperTypeOf($phpStanDocType)->yes();
} }
private function isThisTypeInFinalClass(\PHPStan\Type\Type $phpStanDocType, \PHPStan\Type\Type $phpParserNodeType) : bool private function isThisTypeInFinalClass(\PHPStan\Type\Type $phpStanDocType, \PHPStan\Type\Type $phpParserNodeType, \PhpParser\Node $node) : bool
{ {
/** /**
* Special case for $this/(self|static) compare * Special case for $this/(self|static) compare
@ -273,6 +279,17 @@ final class TypeComparator
* $this refers to the exact object identity, not just the same type. Therefore, it's valid and should not be removed * $this refers to the exact object identity, not just the same type. Therefore, it's valid and should not be removed
* @see https://wiki.php.net/rfc/this_return_type for more context * @see https://wiki.php.net/rfc/this_return_type for more context
*/ */
return !($phpStanDocType instanceof \PHPStan\Type\ThisType && $phpParserNodeType instanceof \PHPStan\Type\StaticType); if ($phpStanDocType instanceof \PHPStan\Type\ThisType && $phpParserNodeType instanceof \PHPStan\Type\StaticType) {
return \false;
}
$isStaticReturnDocTypeWithThisType = $phpStanDocType instanceof \PHPStan\Type\StaticType && $phpParserNodeType instanceof \PHPStan\Type\ThisType;
if (!$isStaticReturnDocTypeWithThisType) {
return \true;
}
$class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class);
if (!$class instanceof \PhpParser\Node\Stmt\Class_) {
return \false;
}
return $class->isFinal();
} }
} }

View File

@ -16,11 +16,11 @@ final class VersionResolver
/** /**
* @var string * @var string
*/ */
public const PACKAGE_VERSION = '8b4c7c5fd8ec764b1dc855d044658d91a81315b3'; public const PACKAGE_VERSION = '12fa9407f734c847cb7739bd435ec42bc66a8f1c';
/** /**
* @var string * @var string
*/ */
public const RELEASE_DATE = '2022-05-11 01:16:01'; public const RELEASE_DATE = '2022-05-11 08:06:19';
/** /**
* @var string * @var string
*/ */

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php'; require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitdef0663bbddfe6c4b9647213fe734d55::getLoader(); return ComposerAutoloaderInitf4d3d73b2d810c5eea9f754f08f9876b::getLoader();

View File

@ -3259,7 +3259,11 @@ return array(
'Ssch\\TYPO3Rector\\Helper\\TcaHelperTrait' => $vendorDir . '/ssch/typo3-rector/src/Helper/TcaHelperTrait.php', 'Ssch\\TYPO3Rector\\Helper\\TcaHelperTrait' => $vendorDir . '/ssch/typo3-rector/src/Helper/TcaHelperTrait.php',
'Ssch\\TYPO3Rector\\Helper\\Typo3NodeResolver' => $vendorDir . '/ssch/typo3-rector/src/Helper/Typo3NodeResolver.php', 'Ssch\\TYPO3Rector\\Helper\\Typo3NodeResolver' => $vendorDir . '/ssch/typo3-rector/src/Helper/Typo3NodeResolver.php',
'Ssch\\TYPO3Rector\\NodeAnalyzer\\ClassConstAnalyzer' => $vendorDir . '/ssch/typo3-rector/src/NodeAnalyzer/ClassConstAnalyzer.php', 'Ssch\\TYPO3Rector\\NodeAnalyzer\\ClassConstAnalyzer' => $vendorDir . '/ssch/typo3-rector/src/NodeAnalyzer/ClassConstAnalyzer.php',
'Ssch\\TYPO3Rector\\NodeAnalyzer\\CommandArrayDecorator' => $vendorDir . '/ssch/typo3-rector/src/NodeAnalyzer/CommandArrayDecorator.php',
'Ssch\\TYPO3Rector\\NodeAnalyzer\\CommandMethodDecorator' => $vendorDir . '/ssch/typo3-rector/src/NodeAnalyzer/CommandMethodDecorator.php',
'Ssch\\TYPO3Rector\\NodeFactory\\CommandArrayItemFactory' => $vendorDir . '/ssch/typo3-rector/src/NodeFactory/CommandArrayItemFactory.php',
'Ssch\\TYPO3Rector\\NodeFactory\\HelperArgumentAssignFactory' => $vendorDir . '/ssch/typo3-rector/src/NodeFactory/HelperArgumentAssignFactory.php', 'Ssch\\TYPO3Rector\\NodeFactory\\HelperArgumentAssignFactory' => $vendorDir . '/ssch/typo3-rector/src/NodeFactory/HelperArgumentAssignFactory.php',
'Ssch\\TYPO3Rector\\NodeFactory\\IconArrayItemFactory' => $vendorDir . '/ssch/typo3-rector/src/NodeFactory/IconArrayItemFactory.php',
'Ssch\\TYPO3Rector\\NodeFactory\\ImportExtbaseAnnotationIfMissingFactory' => $vendorDir . '/ssch/typo3-rector/src/NodeFactory/ImportExtbaseAnnotationIfMissingFactory.php', 'Ssch\\TYPO3Rector\\NodeFactory\\ImportExtbaseAnnotationIfMissingFactory' => $vendorDir . '/ssch/typo3-rector/src/NodeFactory/ImportExtbaseAnnotationIfMissingFactory.php',
'Ssch\\TYPO3Rector\\NodeFactory\\InitializeArgumentsClassMethodFactory' => $vendorDir . '/ssch/typo3-rector/src/NodeFactory/InitializeArgumentsClassMethodFactory.php', 'Ssch\\TYPO3Rector\\NodeFactory\\InitializeArgumentsClassMethodFactory' => $vendorDir . '/ssch/typo3-rector/src/NodeFactory/InitializeArgumentsClassMethodFactory.php',
'Ssch\\TYPO3Rector\\NodeFactory\\InjectMethodFactory' => $vendorDir . '/ssch/typo3-rector/src/NodeFactory/InjectMethodFactory.php', 'Ssch\\TYPO3Rector\\NodeFactory\\InjectMethodFactory' => $vendorDir . '/ssch/typo3-rector/src/NodeFactory/InjectMethodFactory.php',
@ -3339,7 +3343,6 @@ return array(
'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\FlexFormToolsArrayValueByPathRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v11/v5/FlexFormToolsArrayValueByPathRector.php', 'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\FlexFormToolsArrayValueByPathRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v11/v5/FlexFormToolsArrayValueByPathRector.php',
'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\HandleCObjRendererATagParamsMethodRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v11/v5/HandleCObjRendererATagParamsMethodRector.php', 'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\HandleCObjRendererATagParamsMethodRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v11/v5/HandleCObjRendererATagParamsMethodRector.php',
'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\RegisterIconToIconFileRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v11/v5/RegisterIconToIconFileRector.php', 'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\RegisterIconToIconFileRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v11/v5/RegisterIconToIconFileRector.php',
'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\RegisterIconToIconFileRector\\AddIconsToReturnRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v11/v5/RegisterIconToIconFileRector/AddIconsToReturnRector.php',
'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\RemoveDefaultInternalTypeDBRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v11/v5/RemoveDefaultInternalTypeDBRector.php', 'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\RemoveDefaultInternalTypeDBRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v11/v5/RemoveDefaultInternalTypeDBRector.php',
'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\ReplaceTSFEATagParamsCallOnGlobalsRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v11/v5/ReplaceTSFEATagParamsCallOnGlobalsRector.php', 'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\ReplaceTSFEATagParamsCallOnGlobalsRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v11/v5/ReplaceTSFEATagParamsCallOnGlobalsRector.php',
'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\SubstituteBackendTemplateViewWithModuleTemplateRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v11/v5/SubstituteBackendTemplateViewWithModuleTemplateRector.php', 'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\SubstituteBackendTemplateViewWithModuleTemplateRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v11/v5/SubstituteBackendTemplateViewWithModuleTemplateRector.php',
@ -3486,8 +3489,6 @@ return array(
'Ssch\\TYPO3Rector\\Rector\\v9\\v4\\UseSignalAfterExtensionInstallInsteadOfHasInstalledExtensionsRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v9/v4/UseSignalAfterExtensionInstallInsteadOfHasInstalledExtensionsRector.php', 'Ssch\\TYPO3Rector\\Rector\\v9\\v4\\UseSignalAfterExtensionInstallInsteadOfHasInstalledExtensionsRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v9/v4/UseSignalAfterExtensionInstallInsteadOfHasInstalledExtensionsRector.php',
'Ssch\\TYPO3Rector\\Rector\\v9\\v4\\UseSignalTablesDefinitionIsBeingBuiltSqlExpectedSchemaServiceRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v9/v4/UseSignalTablesDefinitionIsBeingBuiltSqlExpectedSchemaServiceRector.php', 'Ssch\\TYPO3Rector\\Rector\\v9\\v4\\UseSignalTablesDefinitionIsBeingBuiltSqlExpectedSchemaServiceRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v9/v4/UseSignalTablesDefinitionIsBeingBuiltSqlExpectedSchemaServiceRector.php',
'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\ExtbaseCommandControllerToSymfonyCommandRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v9/v5/ExtbaseCommandControllerToSymfonyCommandRector.php', 'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\ExtbaseCommandControllerToSymfonyCommandRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v9/v5/ExtbaseCommandControllerToSymfonyCommandRector.php',
'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\ExtbaseCommandControllerToSymfonyCommand\\AddArgumentToSymfonyCommandRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v9/v5/ExtbaseCommandControllerToSymfonyCommand/AddArgumentToSymfonyCommandRector.php',
'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\ExtbaseCommandControllerToSymfonyCommand\\AddCommandsToReturnRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v9/v5/ExtbaseCommandControllerToSymfonyCommand/AddCommandsToReturnRector.php',
'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\RefactorProcessOutputRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v9/v5/RefactorProcessOutputRector.php', 'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\RefactorProcessOutputRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v9/v5/RefactorProcessOutputRector.php',
'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\RefactorPropertiesOfTypoScriptFrontendControllerRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v9/v5/RefactorPropertiesOfTypoScriptFrontendControllerRector.php', 'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\RefactorPropertiesOfTypoScriptFrontendControllerRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v9/v5/RefactorPropertiesOfTypoScriptFrontendControllerRector.php',
'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\RefactorTypeInternalTypeFileAndFileReferenceToFalRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v9/v5/RefactorTypeInternalTypeFileAndFileReferenceToFalRector.php', 'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\RefactorTypeInternalTypeFileAndFileReferenceToFalRector' => $vendorDir . '/ssch/typo3-rector/src/Rector/v9/v5/RefactorTypeInternalTypeFileAndFileReferenceToFalRector.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer // autoload_real.php @generated by Composer
class ComposerAutoloaderInitdef0663bbddfe6c4b9647213fe734d55 class ComposerAutoloaderInitf4d3d73b2d810c5eea9f754f08f9876b
{ {
private static $loader; private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInitdef0663bbddfe6c4b9647213fe734d55
return self::$loader; return self::$loader;
} }
spl_autoload_register(array('ComposerAutoloaderInitdef0663bbddfe6c4b9647213fe734d55', 'loadClassLoader'), true, true); spl_autoload_register(array('ComposerAutoloaderInitf4d3d73b2d810c5eea9f754f08f9876b', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitdef0663bbddfe6c4b9647213fe734d55', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInitf4d3d73b2d810c5eea9f754f08f9876b', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php'; require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitdef0663bbddfe6c4b9647213fe734d55::getInitializer($loader)); call_user_func(\Composer\Autoload\ComposerStaticInitf4d3d73b2d810c5eea9f754f08f9876b::getInitializer($loader));
$loader->setClassMapAuthoritative(true); $loader->setClassMapAuthoritative(true);
$loader->register(true); $loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInitdef0663bbddfe6c4b9647213fe734d55::$files; $includeFiles = \Composer\Autoload\ComposerStaticInitf4d3d73b2d810c5eea9f754f08f9876b::$files;
foreach ($includeFiles as $fileIdentifier => $file) { foreach ($includeFiles as $fileIdentifier => $file) {
composerRequiredef0663bbddfe6c4b9647213fe734d55($fileIdentifier, $file); composerRequiref4d3d73b2d810c5eea9f754f08f9876b($fileIdentifier, $file);
} }
return $loader; return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInitdef0663bbddfe6c4b9647213fe734d55
* @param string $file * @param string $file
* @return void * @return void
*/ */
function composerRequiredef0663bbddfe6c4b9647213fe734d55($fileIdentifier, $file) function composerRequiref4d3d73b2d810c5eea9f754f08f9876b($fileIdentifier, $file)
{ {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload; namespace Composer\Autoload;
class ComposerStaticInitdef0663bbddfe6c4b9647213fe734d55 class ComposerStaticInitf4d3d73b2d810c5eea9f754f08f9876b
{ {
public static $files = array ( public static $files = array (
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
@ -3628,7 +3628,11 @@ class ComposerStaticInitdef0663bbddfe6c4b9647213fe734d55
'Ssch\\TYPO3Rector\\Helper\\TcaHelperTrait' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Helper/TcaHelperTrait.php', 'Ssch\\TYPO3Rector\\Helper\\TcaHelperTrait' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Helper/TcaHelperTrait.php',
'Ssch\\TYPO3Rector\\Helper\\Typo3NodeResolver' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Helper/Typo3NodeResolver.php', 'Ssch\\TYPO3Rector\\Helper\\Typo3NodeResolver' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Helper/Typo3NodeResolver.php',
'Ssch\\TYPO3Rector\\NodeAnalyzer\\ClassConstAnalyzer' => __DIR__ . '/..' . '/ssch/typo3-rector/src/NodeAnalyzer/ClassConstAnalyzer.php', 'Ssch\\TYPO3Rector\\NodeAnalyzer\\ClassConstAnalyzer' => __DIR__ . '/..' . '/ssch/typo3-rector/src/NodeAnalyzer/ClassConstAnalyzer.php',
'Ssch\\TYPO3Rector\\NodeAnalyzer\\CommandArrayDecorator' => __DIR__ . '/..' . '/ssch/typo3-rector/src/NodeAnalyzer/CommandArrayDecorator.php',
'Ssch\\TYPO3Rector\\NodeAnalyzer\\CommandMethodDecorator' => __DIR__ . '/..' . '/ssch/typo3-rector/src/NodeAnalyzer/CommandMethodDecorator.php',
'Ssch\\TYPO3Rector\\NodeFactory\\CommandArrayItemFactory' => __DIR__ . '/..' . '/ssch/typo3-rector/src/NodeFactory/CommandArrayItemFactory.php',
'Ssch\\TYPO3Rector\\NodeFactory\\HelperArgumentAssignFactory' => __DIR__ . '/..' . '/ssch/typo3-rector/src/NodeFactory/HelperArgumentAssignFactory.php', 'Ssch\\TYPO3Rector\\NodeFactory\\HelperArgumentAssignFactory' => __DIR__ . '/..' . '/ssch/typo3-rector/src/NodeFactory/HelperArgumentAssignFactory.php',
'Ssch\\TYPO3Rector\\NodeFactory\\IconArrayItemFactory' => __DIR__ . '/..' . '/ssch/typo3-rector/src/NodeFactory/IconArrayItemFactory.php',
'Ssch\\TYPO3Rector\\NodeFactory\\ImportExtbaseAnnotationIfMissingFactory' => __DIR__ . '/..' . '/ssch/typo3-rector/src/NodeFactory/ImportExtbaseAnnotationIfMissingFactory.php', 'Ssch\\TYPO3Rector\\NodeFactory\\ImportExtbaseAnnotationIfMissingFactory' => __DIR__ . '/..' . '/ssch/typo3-rector/src/NodeFactory/ImportExtbaseAnnotationIfMissingFactory.php',
'Ssch\\TYPO3Rector\\NodeFactory\\InitializeArgumentsClassMethodFactory' => __DIR__ . '/..' . '/ssch/typo3-rector/src/NodeFactory/InitializeArgumentsClassMethodFactory.php', 'Ssch\\TYPO3Rector\\NodeFactory\\InitializeArgumentsClassMethodFactory' => __DIR__ . '/..' . '/ssch/typo3-rector/src/NodeFactory/InitializeArgumentsClassMethodFactory.php',
'Ssch\\TYPO3Rector\\NodeFactory\\InjectMethodFactory' => __DIR__ . '/..' . '/ssch/typo3-rector/src/NodeFactory/InjectMethodFactory.php', 'Ssch\\TYPO3Rector\\NodeFactory\\InjectMethodFactory' => __DIR__ . '/..' . '/ssch/typo3-rector/src/NodeFactory/InjectMethodFactory.php',
@ -3708,7 +3712,6 @@ class ComposerStaticInitdef0663bbddfe6c4b9647213fe734d55
'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\FlexFormToolsArrayValueByPathRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v11/v5/FlexFormToolsArrayValueByPathRector.php', 'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\FlexFormToolsArrayValueByPathRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v11/v5/FlexFormToolsArrayValueByPathRector.php',
'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\HandleCObjRendererATagParamsMethodRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v11/v5/HandleCObjRendererATagParamsMethodRector.php', 'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\HandleCObjRendererATagParamsMethodRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v11/v5/HandleCObjRendererATagParamsMethodRector.php',
'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\RegisterIconToIconFileRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v11/v5/RegisterIconToIconFileRector.php', 'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\RegisterIconToIconFileRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v11/v5/RegisterIconToIconFileRector.php',
'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\RegisterIconToIconFileRector\\AddIconsToReturnRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v11/v5/RegisterIconToIconFileRector/AddIconsToReturnRector.php',
'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\RemoveDefaultInternalTypeDBRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v11/v5/RemoveDefaultInternalTypeDBRector.php', 'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\RemoveDefaultInternalTypeDBRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v11/v5/RemoveDefaultInternalTypeDBRector.php',
'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\ReplaceTSFEATagParamsCallOnGlobalsRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v11/v5/ReplaceTSFEATagParamsCallOnGlobalsRector.php', 'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\ReplaceTSFEATagParamsCallOnGlobalsRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v11/v5/ReplaceTSFEATagParamsCallOnGlobalsRector.php',
'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\SubstituteBackendTemplateViewWithModuleTemplateRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v11/v5/SubstituteBackendTemplateViewWithModuleTemplateRector.php', 'Ssch\\TYPO3Rector\\Rector\\v11\\v5\\SubstituteBackendTemplateViewWithModuleTemplateRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v11/v5/SubstituteBackendTemplateViewWithModuleTemplateRector.php',
@ -3855,8 +3858,6 @@ class ComposerStaticInitdef0663bbddfe6c4b9647213fe734d55
'Ssch\\TYPO3Rector\\Rector\\v9\\v4\\UseSignalAfterExtensionInstallInsteadOfHasInstalledExtensionsRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v9/v4/UseSignalAfterExtensionInstallInsteadOfHasInstalledExtensionsRector.php', 'Ssch\\TYPO3Rector\\Rector\\v9\\v4\\UseSignalAfterExtensionInstallInsteadOfHasInstalledExtensionsRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v9/v4/UseSignalAfterExtensionInstallInsteadOfHasInstalledExtensionsRector.php',
'Ssch\\TYPO3Rector\\Rector\\v9\\v4\\UseSignalTablesDefinitionIsBeingBuiltSqlExpectedSchemaServiceRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v9/v4/UseSignalTablesDefinitionIsBeingBuiltSqlExpectedSchemaServiceRector.php', 'Ssch\\TYPO3Rector\\Rector\\v9\\v4\\UseSignalTablesDefinitionIsBeingBuiltSqlExpectedSchemaServiceRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v9/v4/UseSignalTablesDefinitionIsBeingBuiltSqlExpectedSchemaServiceRector.php',
'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\ExtbaseCommandControllerToSymfonyCommandRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v9/v5/ExtbaseCommandControllerToSymfonyCommandRector.php', 'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\ExtbaseCommandControllerToSymfonyCommandRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v9/v5/ExtbaseCommandControllerToSymfonyCommandRector.php',
'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\ExtbaseCommandControllerToSymfonyCommand\\AddArgumentToSymfonyCommandRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v9/v5/ExtbaseCommandControllerToSymfonyCommand/AddArgumentToSymfonyCommandRector.php',
'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\ExtbaseCommandControllerToSymfonyCommand\\AddCommandsToReturnRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v9/v5/ExtbaseCommandControllerToSymfonyCommand/AddCommandsToReturnRector.php',
'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\RefactorProcessOutputRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v9/v5/RefactorProcessOutputRector.php', 'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\RefactorProcessOutputRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v9/v5/RefactorProcessOutputRector.php',
'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\RefactorPropertiesOfTypoScriptFrontendControllerRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v9/v5/RefactorPropertiesOfTypoScriptFrontendControllerRector.php', 'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\RefactorPropertiesOfTypoScriptFrontendControllerRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v9/v5/RefactorPropertiesOfTypoScriptFrontendControllerRector.php',
'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\RefactorTypeInternalTypeFileAndFileReferenceToFalRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v9/v5/RefactorTypeInternalTypeFileAndFileReferenceToFalRector.php', 'Ssch\\TYPO3Rector\\Rector\\v9\\v5\\RefactorTypeInternalTypeFileAndFileReferenceToFalRector' => __DIR__ . '/..' . '/ssch/typo3-rector/src/Rector/v9/v5/RefactorTypeInternalTypeFileAndFileReferenceToFalRector.php',
@ -3888,9 +3889,9 @@ class ComposerStaticInitdef0663bbddfe6c4b9647213fe734d55
public static function getInitializer(ClassLoader $loader) public static function getInitializer(ClassLoader $loader)
{ {
return \Closure::bind(function () use ($loader) { return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitdef0663bbddfe6c4b9647213fe734d55::$prefixLengthsPsr4; $loader->prefixLengthsPsr4 = ComposerStaticInitf4d3d73b2d810c5eea9f754f08f9876b::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitdef0663bbddfe6c4b9647213fe734d55::$prefixDirsPsr4; $loader->prefixDirsPsr4 = ComposerStaticInitf4d3d73b2d810c5eea9f754f08f9876b::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitdef0663bbddfe6c4b9647213fe734d55::$classMap; $loader->classMap = ComposerStaticInitf4d3d73b2d810c5eea9f754f08f9876b::$classMap;
}, null, ClassLoader::class); }, null, ClassLoader::class);
} }

View File

@ -2784,12 +2784,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https:\/\/github.com\/sabbelasichon\/typo3-rector.git", "url": "https:\/\/github.com\/sabbelasichon\/typo3-rector.git",
"reference": "781bb2a5cd95af5fd2494b162cd957a2cc26de44" "reference": "0da9d196fe20e6d377236f038c6203db31ad3d67"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https:\/\/api.github.com\/repos\/sabbelasichon\/typo3-rector\/zipball\/781bb2a5cd95af5fd2494b162cd957a2cc26de44", "url": "https:\/\/api.github.com\/repos\/sabbelasichon\/typo3-rector\/zipball\/0da9d196fe20e6d377236f038c6203db31ad3d67",
"reference": "781bb2a5cd95af5fd2494b162cd957a2cc26de44", "reference": "0da9d196fe20e6d377236f038c6203db31ad3d67",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2807,9 +2807,9 @@
"phpstan\/extension-installer": "^1.1", "phpstan\/extension-installer": "^1.1",
"phpstan\/phpstan": "^1.3", "phpstan\/phpstan": "^1.3",
"phpunit\/phpunit": "^9.5", "phpunit\/phpunit": "^9.5",
"rector\/phpstan-rules": "^0.4.20", "rector\/phpstan-rules": "^0.5",
"rector\/rector-generator": "dev-main", "rector\/rector-generator": "dev-main",
"rector\/rector-src": "dev-main", "rector\/rector-src": "dev-main#28fb30f",
"symfony\/console": "^6.0", "symfony\/console": "^6.0",
"symplify\/coding-standard": "^10.2", "symplify\/coding-standard": "^10.2",
"symplify\/easy-coding-standard": "^10.2", "symplify\/easy-coding-standard": "^10.2",
@ -2819,7 +2819,7 @@
"symplify\/vendor-patches": "^10.2", "symplify\/vendor-patches": "^10.2",
"tracy\/tracy": "^2.8" "tracy\/tracy": "^2.8"
}, },
"time": "2022-05-10T18:27:04+00:00", "time": "2022-05-11T03:55:23+00:00",
"default-branch": true, "default-branch": true,
"type": "rector-extension", "type": "rector-extension",
"extra": { "extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/ */
final class GeneratedConfig final class GeneratedConfig
{ {
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 43ca394'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 77c17ba'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 784271e'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 352a13b'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e048bfd'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e544f2a'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 666c8d7'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 642ada3'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 781bb2a')); public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 43ca394'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 77c17ba'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 784271e'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 352a13b'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e048bfd'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e544f2a'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 666c8d7'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 642ada3'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 0da9d19'));
private function __construct() private function __construct()
{ {
} }

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) { if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20220511\AutoloadIncluder'); spl_autoload_call('RectorPrefix20220511\AutoloadIncluder');
} }
if (!class_exists('ComposerAutoloaderInitdef0663bbddfe6c4b9647213fe734d55', false) && !interface_exists('ComposerAutoloaderInitdef0663bbddfe6c4b9647213fe734d55', false) && !trait_exists('ComposerAutoloaderInitdef0663bbddfe6c4b9647213fe734d55', false)) { if (!class_exists('ComposerAutoloaderInitf4d3d73b2d810c5eea9f754f08f9876b', false) && !interface_exists('ComposerAutoloaderInitf4d3d73b2d810c5eea9f754f08f9876b', false) && !trait_exists('ComposerAutoloaderInitf4d3d73b2d810c5eea9f754f08f9876b', false)) {
spl_autoload_call('RectorPrefix20220511\ComposerAutoloaderInitdef0663bbddfe6c4b9647213fe734d55'); spl_autoload_call('RectorPrefix20220511\ComposerAutoloaderInitf4d3d73b2d810c5eea9f754f08f9876b');
} }
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) { if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20220511\Helmich\TypoScriptParser\Parser\AST\Statement'); spl_autoload_call('RectorPrefix20220511\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20220511\print_node(...func_get_args()); return \RectorPrefix20220511\print_node(...func_get_args());
} }
} }
if (!function_exists('composerRequiredef0663bbddfe6c4b9647213fe734d55')) { if (!function_exists('composerRequiref4d3d73b2d810c5eea9f754f08f9876b')) {
function composerRequiredef0663bbddfe6c4b9647213fe734d55() { function composerRequiref4d3d73b2d810c5eea9f754f08f9876b() {
return \RectorPrefix20220511\composerRequiredef0663bbddfe6c4b9647213fe734d55(...func_get_args()); return \RectorPrefix20220511\composerRequiref4d3d73b2d810c5eea9f754f08f9876b(...func_get_args());
} }
} }
if (!function_exists('scanPath')) { if (!function_exists('scanPath')) {

View File

@ -28,9 +28,9 @@
"phpstan\/extension-installer": "^1.1", "phpstan\/extension-installer": "^1.1",
"phpstan\/phpstan": "^1.3", "phpstan\/phpstan": "^1.3",
"phpunit\/phpunit": "^9.5", "phpunit\/phpunit": "^9.5",
"rector\/phpstan-rules": "^0.4.20", "rector\/phpstan-rules": "^0.5",
"rector\/rector-generator": "dev-main", "rector\/rector-generator": "dev-main",
"rector\/rector-src": "dev-main", "rector\/rector-src": "dev-main#28fb30f",
"symfony\/console": "^6.0", "symfony\/console": "^6.0",
"symplify\/coding-standard": "^10.2", "symplify\/coding-standard": "^10.2",
"symplify\/easy-coding-standard": "^10.2", "symplify\/easy-coding-standard": "^10.2",

View File

@ -4,12 +4,8 @@ declare (strict_types=1);
namespace RectorPrefix20220511; namespace RectorPrefix20220511;
use Rector\Config\RectorConfig; use Rector\Config\RectorConfig;
use Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddArgumentToSymfonyCommandRector;
use Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddCommandsToReturnRector;
use Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommandRector; use Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommandRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void { return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->import(__DIR__ . '/../config.php'); $rectorConfig->import(__DIR__ . '/../config.php');
$rectorConfig->rule(\Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddArgumentToSymfonyCommandRector::class);
$rectorConfig->rule(\Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddCommandsToReturnRector::class);
$rectorConfig->rule(\Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommandRector::class); $rectorConfig->rule(\Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommandRector::class);
}; };

View File

@ -5,9 +5,7 @@ namespace RectorPrefix20220511;
use Rector\Config\RectorConfig; use Rector\Config\RectorConfig;
use Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector; use Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector;
use Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector\AddIconsToReturnRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void { return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->import(__DIR__ . '/../config.php'); $rectorConfig->import(__DIR__ . '/../config.php');
$rectorConfig->rule(\Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector\AddIconsToReturnRector::class);
$rectorConfig->rule(\Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector::class); $rectorConfig->rule(\Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector::class);
}; };

View File

@ -1,105 +1,4 @@
# 238 Rules Overview # 235 Rules Overview
## AddArgumentToSymfonyCommandRector
Add arguments to configure and executed method in Symfony Command
:wrench: **configure it!**
- class: [`Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddArgumentToSymfonyCommandRector`](../src/Rector/v9/v5/ExtbaseCommandControllerToSymfonyCommand/AddArgumentToSymfonyCommandRector.php)
```php
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddArgumentToSymfonyCommandRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(AddArgumentToSymfonyCommandRector::class, [Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddArgumentToSymfonyCommandRector::INPUT_ARGUMENTS: ['foo' => ['name' => 'foo', 'description' => 'The parameter foo', 'mode' => 1, 'default' => null]]]);
};
```
```diff
protected function configure(): void
{
$this->setDescription('This is the description of the command');
+ $this->addArgument('foo', \Symfony\Component\Console\Input\InputArgument::REQUIRED, 'The parameter foo', null);
}
```
<br>
## AddCommandsToReturnRector
Add arguments to configure method in Symfony Command
:wrench: **configure it!**
- class: [`Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddCommandsToReturnRector`](../src/Rector/v9/v5/ExtbaseCommandControllerToSymfonyCommand/AddCommandsToReturnRector.php)
```php
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddCommandsToReturnRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(AddCommandsToReturnRector::class, [Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddCommandsToReturnRector::COMMANDS: ['Command' => 'Command']]);
};
```
```diff
protected function configure(): void
{
$this->setDescription('This is the description of the command');
+ $this->addArgument('foo', \Symfony\Component\Console\Input\InputArgument::REQUIRED, 'The foo argument', null);
}
```
<br>
## AddIconsToReturnRector
Add arguments to configure method in Symfony Command
:wrench: **configure it!**
- class: [`Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector\AddIconsToReturnRector`](../src/Rector/v11/v5/RegisterIconToIconFileRector/AddIconsToReturnRector.php)
```php
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector\AddIconsToReturnRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(AddIconsToReturnRector::class, [Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector\AddIconsToReturnRector::ICON_IDENTIFIER: 'my-icon', Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector\AddIconsToReturnRector::ICON_CONFIGURATION: ['provider' => 'stdClass', 'source' => 'mysvg.svg']]);
};
```
```diff
-return [];
+return [
+ 'my-icon' => [
+ 'provider' => stdClass::class,
+ 'source' => 'mysvg.svg'
+ ]
+];
```
<br>
## AddRenderTypeToSelectFieldRector ## AddRenderTypeToSelectFieldRector

View File

@ -0,0 +1,40 @@
<?php
declare (strict_types=1);
namespace Ssch\TYPO3Rector\NodeAnalyzer;
use PhpParser\Node\Expr\Array_;
use Rector\Core\PhpParser\Node\Value\ValueResolver;
use Ssch\TYPO3Rector\NodeFactory\CommandArrayItemFactory;
final class CommandArrayDecorator
{
/**
* @readonly
* @var \Ssch\TYPO3Rector\NodeFactory\CommandArrayItemFactory
*/
private $commandArrayItemFactory;
/**
* @readonly
* @var \Rector\Core\PhpParser\Node\Value\ValueResolver
*/
private $valueResolver;
public function __construct(\Ssch\TYPO3Rector\NodeFactory\CommandArrayItemFactory $commandArrayItemFactory, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver)
{
$this->commandArrayItemFactory = $commandArrayItemFactory;
$this->valueResolver = $valueResolver;
}
/**
* @param array<string, mixed> $commands
*/
public function decorateArray(\PhpParser\Node\Expr\Array_ $array, array $commands) : void
{
$existingCommands = $this->valueResolver->getValue($array) ?? [];
$commands = \array_filter($commands, function (string $command) use($existingCommands) {
return \array_reduce($existingCommands, function ($carry, $existingCommand) use($command) {
return $existingCommand['class'] !== $command && $carry;
}, \true);
});
$arrayItems = $this->commandArrayItemFactory->createArrayItems($commands);
$array->items = \array_merge($array->items, $arrayItems);
}
}

View File

@ -0,0 +1,87 @@
<?php
declare (strict_types=1);
namespace Ssch\TYPO3Rector\NodeAnalyzer;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
use Rector\Core\PhpParser\Node\NodeFactory;
use Rector\NodeNameResolver\NodeNameResolver;
use RectorPrefix20220511\Symfony\Component\Console\Input\InputArgument;
final class CommandMethodDecorator
{
/**
* @var array<int, string>
*/
private const MODE_MAPPING = [\RectorPrefix20220511\Symfony\Component\Console\Input\InputArgument::OPTIONAL => 'OPTIONAL', \RectorPrefix20220511\Symfony\Component\Console\Input\InputArgument::REQUIRED => 'REQUIRED'];
/**
* @readonly
* @var \Rector\Core\PhpParser\Node\NodeFactory
*/
private $nodeFactory;
/**
* @readonly
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver)
{
$this->nodeFactory = $nodeFactory;
$this->nodeNameResolver = $nodeNameResolver;
}
/**
* @param array<array{mode: int, name: string, description: string, default: mixed}> $commandInputArguments
*/
public function decorate(\PhpParser\Node\Stmt\ClassMethod $classMethod, array $commandInputArguments) : void
{
if ([] === $commandInputArguments) {
return;
}
if ($this->nodeNameResolver->isName($classMethod->name, 'configure')) {
$this->addArgumentsToConfigureMethod($classMethod, $commandInputArguments);
return;
}
if ($this->nodeNameResolver->isName($classMethod->name, 'execute')) {
$this->addArgumentsToExecuteMethod($classMethod, $commandInputArguments);
}
}
/**
* @param array<array{mode: int, name: string, description: string, default: mixed}> $commandInputArguments
*/
private function addArgumentsToConfigureMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod, array $commandInputArguments) : void
{
foreach ($commandInputArguments as $commandInputArgument) {
$mode = $this->createMode((int) $commandInputArgument['mode']);
$name = new \PhpParser\Node\Scalar\String_($commandInputArgument['name']);
$description = new \PhpParser\Node\Scalar\String_($commandInputArgument['description']);
$defaultValue = $commandInputArgument['default'];
$classMethod->stmts[] = new \PhpParser\Node\Stmt\Expression($this->nodeFactory->createMethodCall('this', 'addArgument', [$name, $mode, $description, $defaultValue]));
}
}
/**
* @param array<array{mode: int, name: string, description: string, default: mixed}> $commandInputArguments
*/
private function addArgumentsToExecuteMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod, array $commandInputArguments) : void
{
if (null === $classMethod->stmts) {
return;
}
$argumentStatements = [];
foreach ($commandInputArguments as $commandInputArgument) {
$name = $commandInputArgument['name'];
$variable = new \PhpParser\Node\Expr\Variable($name);
$inputMethodCall = $this->nodeFactory->createMethodCall('input', 'getArgument', [$name]);
$assignment = new \PhpParser\Node\Expr\Assign($variable, $inputMethodCall);
$argumentStatements[] = new \PhpParser\Node\Stmt\Expression($assignment);
}
\array_unshift($classMethod->stmts, ...$argumentStatements);
}
private function createMode(int $mode) : \PhpParser\Node\Expr\ClassConstFetch
{
return $this->nodeFactory->createClassConstFetch('Symfony\\Component\\Console\\Input\\InputArgument', self::MODE_MAPPING[$mode]);
}
}

View File

@ -0,0 +1,39 @@
<?php
declare (strict_types=1);
namespace Ssch\TYPO3Rector\NodeFactory;
use PhpParser\Comment;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Scalar\String_;
use Rector\Core\PhpParser\Node\NodeFactory;
use Rector\NodeTypeResolver\Node\AttributeKey;
final class CommandArrayItemFactory
{
/**
* @readonly
* @var \Rector\Core\PhpParser\Node\NodeFactory
*/
private $nodeFactory;
public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory)
{
$this->nodeFactory = $nodeFactory;
}
/**
* @param array<string, mixed> $commands
* @return ArrayItem[]
*/
public function createArrayItems(array $commands) : array
{
$arrayItems = [];
foreach ($commands as $commandName => $command) {
$commandArray = new \PhpParser\Node\Expr\Array_();
$value = $this->nodeFactory->createClassConstReference($command);
$key = new \PhpParser\Node\Scalar\String_('class');
$commandArray->items[] = new \PhpParser\Node\Expr\ArrayItem($value, $key, \false, [\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS => [new \PhpParser\Comment(\PHP_EOL)]]);
$arrayItems[] = new \PhpParser\Node\Expr\ArrayItem($commandArray, new \PhpParser\Node\Scalar\String_($commandName), \false, [\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS => [new \PhpParser\Comment(\PHP_EOL)]]);
}
return $arrayItems;
}
}

View File

@ -0,0 +1,33 @@
<?php
declare (strict_types=1);
namespace Ssch\TYPO3Rector\NodeFactory;
use PhpParser\Comment;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Scalar\String_;
use Rector\Core\PhpParser\Node\NodeFactory;
use Rector\NodeTypeResolver\Node\AttributeKey;
final class IconArrayItemFactory
{
/**
* @readonly
* @var \Rector\Core\PhpParser\Node\NodeFactory
*/
private $nodeFactory;
public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory)
{
$this->nodeFactory = $nodeFactory;
}
/**
* @param array<string, mixed> $iconConfiguration
*/
public function create(array $iconConfiguration, string $iconIdentifier) : \PhpParser\Node\Expr\ArrayItem
{
$value = $this->nodeFactory->createArray($iconConfiguration);
$key = new \PhpParser\Node\Scalar\String_($iconIdentifier);
// hack to make array item print on a new line
$attributes = [\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS => [new \PhpParser\Comment(\PHP_EOL)]];
return new \PhpParser\Node\Expr\ArrayItem($value, $key, \false, $attributes);
}
}

View File

@ -5,11 +5,10 @@ namespace Ssch\TYPO3Rector\Rector\v11\v5;
use RectorPrefix20220511\Nette\Utils\Strings; use RectorPrefix20220511\Nette\Utils\Strings;
use PhpParser\Node; use PhpParser\Node;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Return_; use PhpParser\Node\Stmt\Return_;
use PhpParser\NodeTraverser; use PhpParser\NodeTraverser;
use PhpParser\NodeVisitor\NameResolver;
use PHPStan\Type\ObjectType; use PHPStan\Type\ObjectType;
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector; use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector;
use Rector\Core\Contract\PhpParser\NodePrinterInterface; use Rector\Core\Contract\PhpParser\NodePrinterInterface;
@ -17,7 +16,7 @@ use Rector\Core\PhpParser\Parser\SimplePhpParser;
use Rector\Core\Rector\AbstractRector; use Rector\Core\Rector\AbstractRector;
use Rector\FileSystemRector\ValueObject\AddedFileWithContent; use Rector\FileSystemRector\ValueObject\AddedFileWithContent;
use Ssch\TYPO3Rector\Helper\FilesFinder; use Ssch\TYPO3Rector\Helper\FilesFinder;
use Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector\AddIconsToReturnRector; use Ssch\TYPO3Rector\NodeFactory\IconArrayItemFactory;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use Symplify\SmartFileSystem\SmartFileInfo; use Symplify\SmartFileSystem\SmartFileInfo;
@ -36,11 +35,6 @@ final class RegisterIconToIconFileRector extends \Rector\Core\Rector\AbstractRec
* @var \Ssch\TYPO3Rector\Helper\FilesFinder * @var \Ssch\TYPO3Rector\Helper\FilesFinder
*/ */
private $filesFinder; private $filesFinder;
/**
* @readonly
* @var \Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector\AddIconsToReturnRector
*/
private $addIconsToReturnRector;
/** /**
* @readonly * @readonly
* @var \Rector\Core\PhpParser\Parser\SimplePhpParser * @var \Rector\Core\PhpParser\Parser\SimplePhpParser
@ -56,13 +50,18 @@ final class RegisterIconToIconFileRector extends \Rector\Core\Rector\AbstractRec
* @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector * @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector
*/ */
private $removedAndAddedFilesCollector; private $removedAndAddedFilesCollector;
public function __construct(\Ssch\TYPO3Rector\Helper\FilesFinder $filesFinder, \Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector\AddIconsToReturnRector $addIconsToReturnRector, \Rector\Core\PhpParser\Parser\SimplePhpParser $simplePhpParser, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) /**
* @readonly
* @var \Ssch\TYPO3Rector\NodeFactory\IconArrayItemFactory
*/
private $iconArrayItemFactory;
public function __construct(\Ssch\TYPO3Rector\Helper\FilesFinder $filesFinder, \Rector\Core\PhpParser\Parser\SimplePhpParser $simplePhpParser, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \Ssch\TYPO3Rector\NodeFactory\IconArrayItemFactory $iconArrayItemFactory)
{ {
$this->filesFinder = $filesFinder; $this->filesFinder = $filesFinder;
$this->addIconsToReturnRector = $addIconsToReturnRector;
$this->simplePhpParser = $simplePhpParser; $this->simplePhpParser = $simplePhpParser;
$this->nodePrinter = $nodePrinter; $this->nodePrinter = $nodePrinter;
$this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector; $this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector;
$this->iconArrayItemFactory = $iconArrayItemFactory;
} }
/** /**
* @return array<class-string<Node>> * @return array<class-string<Node>>
@ -108,7 +107,6 @@ final class RegisterIconToIconFileRector extends \Rector\Core\Rector\AbstractRec
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{ {
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Generate or add registerIcon calls to Icons.php file', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Generate or add registerIcon calls to Icons.php file', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
use TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider; use TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider;
use TYPO3\CMS\Core\Imaging\IconRegistry; use TYPO3\CMS\Core\Imaging\IconRegistry;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
@ -133,16 +131,6 @@ $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
CODE_SAMPLE CODE_SAMPLE
)]); )]);
} }
/**
* @param Stmt[] $stmts
*/
private function decorateNamesToFullyQualified(array $stmts) : void
{
// decorate nodes with names first
$nameResolverNodeTraverser = new \PhpParser\NodeTraverser();
$nameResolverNodeTraverser->addVisitor(new \PhpParser\NodeVisitor\NameResolver());
$nameResolverNodeTraverser->traverse($stmts);
}
/** /**
* @param array<string, mixed> $iconConfiguration * @param array<string, mixed> $iconConfiguration
*/ */
@ -155,17 +143,20 @@ CODE_SAMPLE
$existingIcons = $addedFileWithContent->getFileContent(); $existingIcons = $addedFileWithContent->getFileContent();
} }
} }
$iconArrayItem = $this->iconArrayItemFactory->create($iconConfiguration, $iconIdentifier);
if (\is_string($existingIcons)) { if (\is_string($existingIcons)) {
$stmts = $this->simplePhpParser->parseString($existingIcons); $stmts = $this->simplePhpParser->parseString($existingIcons);
$this->traverseNodesWithCallable($stmts, function (\PhpParser\Node $node) use($iconArrayItem) {
if (!$node instanceof \PhpParser\Node\Expr\Array_) {
return null;
}
$node->items[] = $iconArrayItem;
return \PhpParser\NodeTraverser::DONT_TRAVERSE_CHILDREN;
});
} else { } else {
$stmts = [new \PhpParser\Node\Stmt\Return_($this->nodeFactory->createArray([]))]; $array = new \PhpParser\Node\Expr\Array_([$iconArrayItem]);
$stmts = [new \PhpParser\Node\Stmt\Return_($array)];
} }
$this->decorateNamesToFullyQualified($stmts);
$nodeTraverser = new \PhpParser\NodeTraverser();
$this->addIconsToReturnRector->configure([\Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector\AddIconsToReturnRector::ICON_IDENTIFIER => $iconIdentifier, \Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector\AddIconsToReturnRector::ICON_CONFIGURATION => $iconConfiguration]);
$nodeTraverser->addVisitor($this->addIconsToReturnRector);
/** @var Stmt[] $stmts */
$stmts = $nodeTraverser->traverse($stmts);
$changedIconsContent = $this->nodePrinter->prettyPrintFile($stmts); $changedIconsContent = $this->nodePrinter->prettyPrintFile($stmts);
$changedIconsContent = \RectorPrefix20220511\Nette\Utils\Strings::replace($changedIconsContent, self::REMOVE_EMPTY_LINES); $changedIconsContent = \RectorPrefix20220511\Nette\Utils\Strings::replace($changedIconsContent, self::REMOVE_EMPTY_LINES);
$this->removedAndAddedFilesCollector->addAddedFile(new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($iconsFilePath, $changedIconsContent)); $this->removedAndAddedFilesCollector->addAddedFile(new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($iconsFilePath, $changedIconsContent));

View File

@ -1,88 +0,0 @@
<?php
declare (strict_types=1);
namespace Ssch\TYPO3Rector\Rector\v11\v5\RegisterIconToIconFileRector;
use PhpParser\Comment;
use PhpParser\Node;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Return_;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\NodeTypeResolver\Node\AttributeKey;
use stdClass;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use RectorPrefix20220511\Webmozart\Assert\Assert;
/**
* @changelog https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Icon/Index.html
* @see \Ssch\TYPO3Rector\Tests\Rector\v11\v5\RegisterIconToIconFileRector\RegisterIconToIconFileRectorTest
*/
final class AddIconsToReturnRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface
{
/**
* @var string
*/
public const ICON_IDENTIFIER = 'icon-identifier';
/**
* @var string
*/
public const ICON_CONFIGURATION = 'icon-configuration';
/**
* @var string
*/
private $iconIdentifier;
/**
* @var array<string, mixed>
*/
private $iconConfiguration = [];
/**
* @codeCoverageIgnore
*/
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add arguments to configure method in Symfony Command', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE'
return [];
CODE_SAMPLE
, <<<'CODE_SAMPLE'
return [
'my-icon' => [
'provider' => stdClass::class,
'source' => 'mysvg.svg'
]
];
CODE_SAMPLE
, [self::ICON_IDENTIFIER => 'my-icon', self::ICON_CONFIGURATION => ['provider' => \stdClass::class, 'source' => 'mysvg.svg']])]);
}
public function getNodeTypes() : array
{
return [\PhpParser\Node\Stmt\Return_::class];
}
/**
* @param Return_ $node
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
if (!$node->expr instanceof \PhpParser\Node\Expr\Array_) {
return null;
}
$iconArrayItem = new \PhpParser\Node\Expr\ArrayItem($this->nodeFactory->createArray($this->iconConfiguration), new \PhpParser\Node\Scalar\String_($this->iconIdentifier), \false, [\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS => [new \PhpParser\Comment(\PHP_EOL)]]);
$node->expr->items[] = $iconArrayItem;
return $node;
}
/**
* @param array<string, mixed> $configuration
*/
public function configure(array $configuration) : void
{
$iconIdentifier = $configuration[self::ICON_IDENTIFIER] ?? '';
$iconConfiguration = $configuration[self::ICON_CONFIGURATION] ?? [];
\RectorPrefix20220511\Webmozart\Assert\Assert::stringNotEmpty($iconIdentifier);
\RectorPrefix20220511\Webmozart\Assert\Assert::isArray($iconConfiguration);
\RectorPrefix20220511\Webmozart\Assert\Assert::keyExists($iconConfiguration, 'provider');
$this->iconConfiguration = $iconConfiguration;
$this->iconIdentifier = $iconIdentifier;
}
}

View File

@ -1,121 +0,0 @@
<?php
declare (strict_types=1);
namespace Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand;
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @changelog https://docs.typo3.org/m/typo3/reference-coreapi/9.5/en-us/ApiOverview/CommandControllers/Index.html
* @see \Ssch\TYPO3Rector\Tests\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommandRector\ExtbaseCommandControllerToSymfonyCommandRectorTest
*/
final class AddArgumentToSymfonyCommandRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface
{
/**
* @var string
*/
public const INPUT_ARGUMENTS = 'input-arguments';
/**
* @var array<int, string>
*/
private const MODE_MAPPING = [2 => 'OPTIONAL', 1 => 'REQUIRED'];
/**
* @var string
*/
private const NAME = 'name';
/**
* @var array<string, array<string, mixed>>
*/
private $commandInputArguments = [];
/**
* @codeCoverageIgnore
*/
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add arguments to configure and executed method in Symfony Command', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE'
protected function configure(): void
{
$this->setDescription('This is the description of the command');
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
protected function configure(): void
{
$this->setDescription('This is the description of the command');
$this->addArgument('foo', \Symfony\Component\Console\Input\InputArgument::REQUIRED, 'The parameter foo', null);
}
CODE_SAMPLE
, [self::INPUT_ARGUMENTS => ['foo' => [self::NAME => 'foo', 'description' => 'The parameter foo', 'mode' => 1, 'default' => null]]])]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [\PhpParser\Node\Stmt\ClassMethod::class];
}
/**
* @param ClassMethod $node
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
if ([] === $this->commandInputArguments) {
return null;
}
if ($this->isName($node->name, 'configure')) {
return $this->addArgumentsToConfigureMethod($node);
}
if ($this->isName($node->name, 'execute')) {
return $this->addArgumentsToExecuteMethod($node);
}
return null;
}
/**
* @param array<string, mixed> $configuration
*/
public function configure(array $configuration) : void
{
$commandInputArguments = $configuration[self::INPUT_ARGUMENTS] ?? [];
$this->commandInputArguments = $commandInputArguments;
}
private function addArgumentsToConfigureMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : \PhpParser\Node\Stmt\ClassMethod
{
foreach ($this->commandInputArguments as $commandInputArgument) {
$mode = $this->createMode((int) $commandInputArgument['mode']);
$name = new \PhpParser\Node\Scalar\String_($commandInputArgument[self::NAME]);
$description = new \PhpParser\Node\Scalar\String_($commandInputArgument['description']);
$defaultValue = $commandInputArgument['default'];
$classMethod->stmts[] = new \PhpParser\Node\Stmt\Expression($this->nodeFactory->createMethodCall('this', 'addArgument', [$name, $mode, $description, $defaultValue]));
}
return $classMethod;
}
private function addArgumentsToExecuteMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : \PhpParser\Node\Stmt\ClassMethod
{
if (null === $classMethod->stmts) {
return $classMethod;
}
$argumentStatements = [];
foreach ($this->commandInputArguments as $commandInputArgument) {
$name = $commandInputArgument[self::NAME];
$variable = new \PhpParser\Node\Expr\Variable($name);
$inputMethodCall = $this->nodeFactory->createMethodCall('input', 'getArgument', [$name]);
$assignment = new \PhpParser\Node\Expr\Assign($variable, $inputMethodCall);
$argumentStatements[] = new \PhpParser\Node\Stmt\Expression($assignment);
}
\array_unshift($classMethod->stmts, ...$argumentStatements);
return $classMethod;
}
private function createMode(int $mode) : \PhpParser\Node\Expr\ClassConstFetch
{
return $this->nodeFactory->createClassConstFetch('Symfony\\Component\\Console\\Input\\InputArgument', self::MODE_MAPPING[$mode]);
}
}

View File

@ -1,87 +0,0 @@
<?php
declare (strict_types=1);
namespace Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand;
use PhpParser\Comment;
use PhpParser\Node;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Return_;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @changelog https://docs.typo3.org/m/typo3/reference-coreapi/9.5/en-us/ApiOverview/CommandControllers/Index.html
* @see \Ssch\TYPO3Rector\Tests\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommandRector\ExtbaseCommandControllerToSymfonyCommandRectorTest
*/
final class AddCommandsToReturnRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface
{
/**
* @var string
*/
public const COMMANDS = 'commands';
/**
* @var string[]
*/
private $commands = [];
/**
* @codeCoverageIgnore
*/
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add arguments to configure method in Symfony Command', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE'
protected function configure(): void
{
$this->setDescription('This is the description of the command');
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
protected function configure(): void
{
$this->setDescription('This is the description of the command');
$this->addArgument('foo', \Symfony\Component\Console\Input\InputArgument::REQUIRED, 'The foo argument', null);
}
CODE_SAMPLE
, [self::COMMANDS => ['Command' => 'Command']])]);
}
public function getNodeTypes() : array
{
return [\PhpParser\Node\Stmt\Return_::class];
}
/**
* @param Return_ $node
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
if ([] === $this->commands) {
return null;
}
if (!$node->expr instanceof \PhpParser\Node\Expr\Array_) {
return null;
}
$existingCommands = $this->valueResolver->getValue($node->expr) ?? [];
$commands = \array_filter($this->commands, function (string $command) use($existingCommands) {
return \array_reduce($existingCommands, function ($carry, $existingCommand) use($command) {
return $existingCommand['class'] !== $command && $carry;
}, \true);
});
foreach ($commands as $commandName => $command) {
$commandArray = new \PhpParser\Node\Expr\Array_();
$commandArray->items[] = new \PhpParser\Node\Expr\ArrayItem($this->nodeFactory->createClassConstReference($command), new \PhpParser\Node\Scalar\String_('class'), \false, [\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS => [new \PhpParser\Comment(\PHP_EOL)]]);
$node->expr->items[] = new \PhpParser\Node\Expr\ArrayItem($commandArray, new \PhpParser\Node\Scalar\String_($commandName), \false, [\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS => [new \PhpParser\Comment(\PHP_EOL)]]);
}
return $node;
}
/**
* @param array<string, mixed> $configuration
*/
public function configure(array $configuration) : void
{
$commandInputArguments = $configuration[self::COMMANDS] ?? [];
$this->commands = $commandInputArguments;
}
}

View File

@ -5,12 +5,12 @@ namespace Ssch\TYPO3Rector\Rector\v9\v5;
use RectorPrefix20220511\Nette\Utils\Strings; use RectorPrefix20220511\Nette\Utils\Strings;
use PhpParser\Node; use PhpParser\Node;
use PhpParser\Node\Stmt; use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Return_; use PhpParser\Node\Stmt\Return_;
use PhpParser\NodeTraverser; use PhpParser\NodeTraverser;
use PhpParser\NodeVisitor\NameResolver; use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode;
use PHPStan\Type\ObjectType; use PHPStan\Type\ObjectType;
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector; use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector;
@ -21,9 +21,10 @@ use Rector\Core\Rector\AbstractRector;
use Rector\FileSystemRector\ValueObject\AddedFileWithContent; use Rector\FileSystemRector\ValueObject\AddedFileWithContent;
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment; use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
use Ssch\TYPO3Rector\Helper\FilesFinder; use Ssch\TYPO3Rector\Helper\FilesFinder;
use Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddArgumentToSymfonyCommandRector; use Ssch\TYPO3Rector\NodeAnalyzer\CommandArrayDecorator;
use Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddCommandsToReturnRector; use Ssch\TYPO3Rector\NodeAnalyzer\CommandMethodDecorator;
use Ssch\TYPO3Rector\Template\TemplateFinder; use Ssch\TYPO3Rector\Template\TemplateFinder;
use RectorPrefix20220511\Symfony\Component\Console\Input\InputArgument;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use Symplify\SmartFileSystem\SmartFileInfo; use Symplify\SmartFileSystem\SmartFileInfo;
@ -48,21 +49,11 @@ final class ExtbaseCommandControllerToSymfonyCommandRector extends \Rector\Core\
* @var \Rector\Core\PhpParser\Parser\RectorParser * @var \Rector\Core\PhpParser\Parser\RectorParser
*/ */
private $rectorParser; private $rectorParser;
/**
* @readonly
* @var \Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddArgumentToSymfonyCommandRector
*/
private $addArgumentToSymfonyCommandRector;
/** /**
* @readonly * @readonly
* @var \Ssch\TYPO3Rector\Helper\FilesFinder * @var \Ssch\TYPO3Rector\Helper\FilesFinder
*/ */
private $filesFinder; private $filesFinder;
/**
* @readonly
* @var \Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddCommandsToReturnRector
*/
private $addCommandsToReturnRector;
/** /**
* @readonly * @readonly
* @var \Rector\Core\PhpParser\Parser\SimplePhpParser * @var \Rector\Core\PhpParser\Parser\SimplePhpParser
@ -83,17 +74,27 @@ final class ExtbaseCommandControllerToSymfonyCommandRector extends \Rector\Core\
* @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector * @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector
*/ */
private $removedAndAddedFilesCollector; private $removedAndAddedFilesCollector;
public function __construct(\RectorPrefix20220511\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\PhpParser\Parser\RectorParser $rectorParser, \Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddArgumentToSymfonyCommandRector $addArgumentToSymfonyCommandRector, \Ssch\TYPO3Rector\Helper\FilesFinder $filesFinder, \Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddCommandsToReturnRector $addCommandsToReturnRector, \Rector\Core\PhpParser\Parser\SimplePhpParser $simplePhpParser, \Ssch\TYPO3Rector\Template\TemplateFinder $templateFinder, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) /**
* @readonly
* @var \Ssch\TYPO3Rector\NodeAnalyzer\CommandArrayDecorator
*/
private $commandArrayDecorator;
/**
* @readonly
* @var \Ssch\TYPO3Rector\NodeAnalyzer\CommandMethodDecorator
*/
private $commandMethodDecorator;
public function __construct(\RectorPrefix20220511\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\PhpParser\Parser\RectorParser $rectorParser, \Ssch\TYPO3Rector\Helper\FilesFinder $filesFinder, \Rector\Core\PhpParser\Parser\SimplePhpParser $simplePhpParser, \Ssch\TYPO3Rector\Template\TemplateFinder $templateFinder, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \Ssch\TYPO3Rector\NodeAnalyzer\CommandArrayDecorator $commandArrayDecorator, \Ssch\TYPO3Rector\NodeAnalyzer\CommandMethodDecorator $commandMethodDecorator)
{ {
$this->smartFileSystem = $smartFileSystem; $this->smartFileSystem = $smartFileSystem;
$this->rectorParser = $rectorParser; $this->rectorParser = $rectorParser;
$this->addArgumentToSymfonyCommandRector = $addArgumentToSymfonyCommandRector;
$this->filesFinder = $filesFinder; $this->filesFinder = $filesFinder;
$this->addCommandsToReturnRector = $addCommandsToReturnRector;
$this->simplePhpParser = $simplePhpParser; $this->simplePhpParser = $simplePhpParser;
$this->templateFinder = $templateFinder; $this->templateFinder = $templateFinder;
$this->nodePrinter = $nodePrinter; $this->nodePrinter = $nodePrinter;
$this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector; $this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector;
$this->commandArrayDecorator = $commandArrayDecorator;
$this->commandMethodDecorator = $commandMethodDecorator;
} }
/** /**
* @return array<class-string<Node>> * @return array<class-string<Node>>
@ -110,8 +111,8 @@ final class ExtbaseCommandControllerToSymfonyCommandRector extends \Rector\Core\
if (!$this->isObjectType($node, new \PHPStan\Type\ObjectType('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\CommandController'))) { if (!$this->isObjectType($node, new \PHPStan\Type\ObjectType('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\CommandController'))) {
return null; return null;
} }
$commandMethods = $this->findCommandMethods($node); $commandClassMethods = $this->findCommandMethods($node);
if ([] === $commandMethods) { if ([] === $commandClassMethods) {
return null; return null;
} }
if ([] === $node->namespacedName->parts) { if ([] === $node->namespacedName->parts) {
@ -131,7 +132,7 @@ final class ExtbaseCommandControllerToSymfonyCommandRector extends \Rector\Core\
$commandNamespace = \sprintf('\%s\\%s\\Command', $vendorName, $extensionName); $commandNamespace = \sprintf('\%s\\%s\\Command', $vendorName, $extensionName);
// Collect all new commands // Collect all new commands
$newCommandsWithFullQualifiedNamespace = []; $newCommandsWithFullQualifiedNamespace = [];
foreach ($commandMethods as $commandMethod) { foreach ($commandClassMethods as $commandMethod) {
if (!$commandMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { if (!$commandMethod instanceof \PhpParser\Node\Stmt\ClassMethod) {
continue; continue;
} }
@ -159,34 +160,24 @@ final class ExtbaseCommandControllerToSymfonyCommandRector extends \Rector\Core\
if ($this->smartFileSystem->exists($filePath) && !\Rector\Testing\PHPUnit\StaticPHPUnitEnvironment::isPHPUnitRun()) { if ($this->smartFileSystem->exists($filePath) && !\Rector\Testing\PHPUnit\StaticPHPUnitEnvironment::isPHPUnitRun()) {
continue; continue;
} }
$commandVariables = ['__TEMPLATE_NAMESPACE__' => \ltrim($commandNamespace, '\\'), '__TEMPLATE_COMMAND_NAME__' => $commandName, '__TEMPLATE_DESCRIPTION__' => $commandDescription, '__TEMPLATE_COMMAND_BODY__' => $this->nodePrinter->prettyPrint($commandMethod->stmts)]; $commandVariables = $this->createCommandVariables($commandNamespace, $commandName, $commandDescription, $commandMethod);
// Add traits, other methods etc. to class // Add traits, other methods etc. to class
// Maybe inject dependencies into __constructor // Maybe inject dependencies into __constructor
$commandContent = \str_replace(\array_keys($commandVariables), $commandVariables, $commandContent); $commandContent = \str_replace(\array_keys($commandVariables), $commandVariables, $commandContent);
$stmts = $this->simplePhpParser->parseString($commandContent); $stmts = $this->simplePhpParser->parseString($commandContent);
$this->decorateNamesToFullyQualified($stmts); $inputArguments = $this->createInputArguments($methodParameters, $paramTags);
$nodeTraverser = new \PhpParser\NodeTraverser(); $this->traverseNodesWithCallable($stmts, function (\PhpParser\Node $node) use($inputArguments) {
$inputArguments = []; if (!$node instanceof \PhpParser\Node\Stmt\ClassMethod) {
foreach ($methodParameters as $key => $methodParameter) { return null;
$paramTag = $paramTags[$key] ?? null;
$methodParamName = $this->nodeNameResolver->getName($methodParameter->var);
if (null === $methodParamName) {
continue;
} }
$inputArguments[$methodParamName] = ['name' => $methodParamName, 'description' => null !== $paramTag ? $paramTag->description : '', 'mode' => null !== $methodParameter->default ? 2 : 1, 'default' => $methodParameter->default]; $this->commandMethodDecorator->decorate($node, $inputArguments);
} });
$this->addArgumentToSymfonyCommandRector->configure([\Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddArgumentToSymfonyCommandRector::INPUT_ARGUMENTS => $inputArguments]);
$nodeTraverser->addVisitor($this->addArgumentToSymfonyCommandRector);
/** @var Stmt[] $stmts */
$stmts = $nodeTraverser->traverse($stmts);
$changedSetConfigContent = $this->nodePrinter->prettyPrintFile($stmts); $changedSetConfigContent = $this->nodePrinter->prettyPrintFile($stmts);
$this->removedAndAddedFilesCollector->addAddedFile(new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($filePath, $changedSetConfigContent)); $this->removedAndAddedFilesCollector->addAddedFile(new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($filePath, $changedSetConfigContent));
$newCommandName = \sprintf('%s:%s', \RectorPrefix20220511\Nette\Utils\Strings::lower($vendorName), \RectorPrefix20220511\Nette\Utils\Strings::lower($commandName)); $newCommandName = \sprintf('%s:%s', \RectorPrefix20220511\Nette\Utils\Strings::lower($vendorName), \RectorPrefix20220511\Nette\Utils\Strings::lower($commandName));
$newCommandsWithFullQualifiedNamespace[$newCommandName] = \sprintf('%s\\%s', $commandNamespace, $commandName); $newCommandsWithFullQualifiedNamespace[$newCommandName] = \sprintf('%s\\%s', $commandNamespace, $commandName);
} }
$this->addNewCommandsToCommandsFile($commandsFilePath, $newCommandsWithFullQualifiedNamespace); $this->addNewCommandsToCommandsFile($commandsFilePath, $newCommandsWithFullQualifiedNamespace);
$this->addArgumentToSymfonyCommandRector->configure([\Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddArgumentToSymfonyCommandRector::INPUT_ARGUMENTS => []]);
$this->addCommandsToReturnRector->configure([\Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddCommandsToReturnRector::COMMANDS => []]);
return $node; return $node;
} }
/** /**
@ -232,22 +223,15 @@ CODE_SAMPLE
)]); )]);
} }
/** /**
* @return Node[]|ClassMethod[] * @return ClassMethod[]
*/ */
private function findCommandMethods(\PhpParser\Node\Stmt\Class_ $class) : array private function findCommandMethods(\PhpParser\Node\Stmt\Class_ $class) : array
{ {
return $this->betterNodeFinder->find($class->stmts, function (\PhpParser\Node $node) : bool { return \array_filter($class->getMethods(), function (\PhpParser\Node\Stmt\ClassMethod $classMethod) {
if (!$node instanceof \PhpParser\Node\Stmt\ClassMethod) { if (!$classMethod->isPublic()) {
return \false; return \false;
} }
if (!$node->isPublic()) { return $this->isName($classMethod->name, '*Command');
return \false;
}
$methodName = $this->getName($node->name);
if (null === $methodName) {
return \false;
}
return \substr_compare($methodName, 'Command', -\strlen('Command')) === 0;
}); });
} }
/** /**
@ -258,27 +242,45 @@ CODE_SAMPLE
if ($this->smartFileSystem->exists($commandsFilePath)) { if ($this->smartFileSystem->exists($commandsFilePath)) {
$commandsSmartFileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($commandsFilePath); $commandsSmartFileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($commandsFilePath);
$stmts = $this->rectorParser->parseFile($commandsSmartFileInfo); $stmts = $this->rectorParser->parseFile($commandsSmartFileInfo);
$this->traverseNodesWithCallable($stmts, function (\PhpParser\Node $node) use($newCommandsWithFullQualifiedNamespace) {
if (!$node instanceof \PhpParser\Node\Expr\Array_) {
return null;
}
$this->commandArrayDecorator->decorateArray($node, $newCommandsWithFullQualifiedNamespace);
return \PhpParser\NodeTraverser::DONT_TRAVERSE_CHILDREN;
});
} else { } else {
$stmts = [new \PhpParser\Node\Stmt\Return_($this->nodeFactory->createArray([]))]; $array = new \PhpParser\Node\Expr\Array_();
$this->commandArrayDecorator->decorateArray($array, $newCommandsWithFullQualifiedNamespace);
$stmts = [new \PhpParser\Node\Stmt\Return_($array)];
} }
$this->decorateNamesToFullyQualified($stmts);
$nodeTraverser = new \PhpParser\NodeTraverser();
$this->addCommandsToReturnRector->configure([\Ssch\TYPO3Rector\Rector\v9\v5\ExtbaseCommandControllerToSymfonyCommand\AddCommandsToReturnRector::COMMANDS => $newCommandsWithFullQualifiedNamespace]);
$nodeTraverser->addVisitor($this->addCommandsToReturnRector);
/** @var Stmt[] $stmts */
$stmts = $nodeTraverser->traverse($stmts);
$changedCommandsContent = $this->nodePrinter->prettyPrintFile($stmts); $changedCommandsContent = $this->nodePrinter->prettyPrintFile($stmts);
$changedCommandsContent = \RectorPrefix20220511\Nette\Utils\Strings::replace($changedCommandsContent, self::REMOVE_EMPTY_LINES, ''); $changedCommandsContent = \RectorPrefix20220511\Nette\Utils\Strings::replace($changedCommandsContent, self::REMOVE_EMPTY_LINES, '');
$this->removedAndAddedFilesCollector->addAddedFile(new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($commandsFilePath, $changedCommandsContent)); $this->removedAndAddedFilesCollector->addAddedFile(new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($commandsFilePath, $changedCommandsContent));
} }
/** /**
* @param Stmt[] $stmts * @param array<int, Node\Param> $methodParameters
* @param ParamTagValueNode[] $paramTags
* @return array<string, array{mode: int, name: string, description: string, default: mixed}>
*/ */
private function decorateNamesToFullyQualified(array $stmts) : void private function createInputArguments(array $methodParameters, array $paramTags) : array
{ {
// decorate nodes with names first $inputArguments = [];
$nameResolverNodeTraverser = new \PhpParser\NodeTraverser(); foreach ($methodParameters as $key => $methodParameter) {
$nameResolverNodeTraverser->addVisitor(new \PhpParser\NodeVisitor\NameResolver()); $paramTag = $paramTags[$key] ?? null;
$nameResolverNodeTraverser->traverse($stmts); $methodParamName = $this->nodeNameResolver->getName($methodParameter->var);
if (null === $methodParamName) {
continue;
}
$inputArguments[$methodParamName] = ['name' => $methodParamName, 'description' => null !== $paramTag ? $paramTag->description : '', 'mode' => null !== $methodParameter->default ? \RectorPrefix20220511\Symfony\Component\Console\Input\InputArgument::OPTIONAL : \RectorPrefix20220511\Symfony\Component\Console\Input\InputArgument::REQUIRED, 'default' => $methodParameter->default];
}
return $inputArguments;
}
/**
* @return array<string, mixed>
*/
private function createCommandVariables(string $commandNamespace, string $commandName, string $commandDescription, \PhpParser\Node\Stmt\ClassMethod $commandMethod) : array
{
return ['__TEMPLATE_NAMESPACE__' => \ltrim($commandNamespace, '\\'), '__TEMPLATE_COMMAND_NAME__' => $commandName, '__TEMPLATE_DESCRIPTION__' => $commandDescription, '__TEMPLATE_COMMAND_BODY__' => $this->nodePrinter->prettyPrint((array) $commandMethod->stmts)];
} }
} }