From 20ff21baa0eeaa23694bb66cd6fa7864a67ab9cf Mon Sep 17 00:00:00 2001 From: Simon Schaufelberger Date: Thu, 25 Sep 2025 01:42:35 +0200 Subject: [PATCH 1/6] Add example for issue #9388 --- .../AttributeDecorator.php | 26 +++ .../AttributeDecoratorInterface.php | 14 ++ .../ValidateAttributeDecorator.php | 67 +++++++ .../Issues/Issue9388/Fixture/fixture.php.inc | 33 ++++ tests/Issues/Issue9388/Issue9388Test.php | 36 ++++ .../ExtbaseAnnotationToAttributeRector.php | 185 ++++++++++++++++++ .../Issue9388/config/configured_rule.php | 27 +++ 7 files changed, 388 insertions(+) create mode 100644 tests/Issues/Issue9388/AnnotationToAttribute/AttributeDecorator.php create mode 100644 tests/Issues/Issue9388/AnnotationToAttribute/AttributeDecoratorInterface.php create mode 100644 tests/Issues/Issue9388/AnnotationToAttribute/ValidateAttributeDecorator.php create mode 100644 tests/Issues/Issue9388/Fixture/fixture.php.inc create mode 100644 tests/Issues/Issue9388/Issue9388Test.php create mode 100644 tests/Issues/Issue9388/Rule/ExtbaseAnnotationToAttributeRector.php create mode 100644 tests/Issues/Issue9388/config/configured_rule.php diff --git a/tests/Issues/Issue9388/AnnotationToAttribute/AttributeDecorator.php b/tests/Issues/Issue9388/AnnotationToAttribute/AttributeDecorator.php new file mode 100644 index 00000000000..92674fba7a6 --- /dev/null +++ b/tests/Issues/Issue9388/AnnotationToAttribute/AttributeDecorator.php @@ -0,0 +1,26 @@ +decorators as $decorator) { + if ($decorator->supports($phpAttributeName)) { + $decorator->decorate($attribute); + } + } + } +} diff --git a/tests/Issues/Issue9388/AnnotationToAttribute/AttributeDecoratorInterface.php b/tests/Issues/Issue9388/AnnotationToAttribute/AttributeDecoratorInterface.php new file mode 100644 index 00000000000..bd4ebe11d98 --- /dev/null +++ b/tests/Issues/Issue9388/AnnotationToAttribute/AttributeDecoratorInterface.php @@ -0,0 +1,14 @@ +valueResolver = $valueResolver; + $this->stringClassNameToClassConstantRector = $stringClassNameToClassConstantRector; + } + + public function supports(string $phpAttributeName): bool + { + return $phpAttributeName === 'TYPO3\CMS\Extbase\Annotation\Validate'; + } + + public function decorate(Attribute $attribute): void + { + $newArguments = new Array_(); + + foreach ($attribute->args as $arg) { + $key = $arg->name instanceof Identifier ? new String_($arg->name->toString()) : new String_('validator'); + + if ($this->valueResolver->isValue($key, 'validator')) { + $classNameString = $this->valueResolver->getValue($arg->value); + if (! is_string($classNameString)) { + continue; + } + + $className = ltrim($classNameString, '\\'); + $classConstant = $this->stringClassNameToClassConstantRector->refactor(new String_($className)); + $value = $classConstant instanceof ClassConstFetch ? $classConstant : $arg->value; + } else { + $value = $arg->value; + } + + $newArguments->items[] = new ArrayItem($value, $key); + } + + $attribute->args = [new Arg($newArguments)]; + } +} diff --git a/tests/Issues/Issue9388/Fixture/fixture.php.inc b/tests/Issues/Issue9388/Fixture/fixture.php.inc new file mode 100644 index 00000000000..a6ebb285b9b --- /dev/null +++ b/tests/Issues/Issue9388/Fixture/fixture.php.inc @@ -0,0 +1,33 @@ + 'NotEmpty'])] + protected $name = ''; + + #[\TYPO3\CMS\Extbase\Annotation\Validate(['validator' => 'NotEmpty'])] + protected $thisWorks = ''; +} diff --git a/tests/Issues/Issue9388/Issue9388Test.php b/tests/Issues/Issue9388/Issue9388Test.php new file mode 100644 index 00000000000..0745efa91ab --- /dev/null +++ b/tests/Issues/Issue9388/Issue9388Test.php @@ -0,0 +1,36 @@ +markTestSkipped('Do not execute'); + } + + $this->doTestFile($filePath); + } + + public static function provideData(): Iterator + { + return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/configured_rule.php'; + } +} diff --git a/tests/Issues/Issue9388/Rule/ExtbaseAnnotationToAttributeRector.php b/tests/Issues/Issue9388/Rule/ExtbaseAnnotationToAttributeRector.php new file mode 100644 index 00000000000..dc616a4231f --- /dev/null +++ b/tests/Issues/Issue9388/Rule/ExtbaseAnnotationToAttributeRector.php @@ -0,0 +1,185 @@ +annotationsToAttributes = [ + new AnnotationToAttribute('TYPO3\CMS\Extbase\Annotation\Validate'), + ]; + } + + public function getRuleDefinition(): RuleDefinition + { + return new RuleDefinition('Change annotation to attribute', [new CodeSample( + <<<'CODE_SAMPLE' +use TYPO3\CMS\Extbase\Annotation as Extbase; + +class MyEntity +{ + /** + * @Extbase\ORM\Transient() + */ + protected string $myProperty; +} +CODE_SAMPLE + , + <<<'CODE_SAMPLE' +use TYPO3\CMS\Extbase\Annotation as Extbase; + +class MyEntity +{ + #[Extbase\ORM\Transient()] + protected string $myProperty; +} +CODE_SAMPLE + )]); + } + + public function getNodeTypes(): array + { + return [Property::class]; + } + + /** + * @param Property $node + */ + public function refactor(Node $node): ?Node + { + $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); + if (! $phpDocInfo instanceof PhpDocInfo) { + return null; + } + + $uses = $this->useImportsResolver->resolveBareUses(); + $annotationAttributeGroups = $this->processDoctrineAnnotationClasses($phpDocInfo, $uses); + if ($annotationAttributeGroups === []) { + return null; + } + + $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node); + + foreach ($annotationAttributeGroups as $attributeGroup) { + foreach ($attributeGroup->attrs as $attr) { + $phpAttributeName = $attr->name->getAttribute(AttributeKey::PHP_ATTRIBUTE_NAME); + $this->attributeDecorator->decorate($phpAttributeName, $attr); + } + } + + $node->attrGroups = \array_merge($node->attrGroups, $annotationAttributeGroups); + return $node; + } + + public function provideMinPhpVersion(): int + { + return PhpVersionFeature::ATTRIBUTES; + } + + /** + * @param Use_[] $uses + * @return AttributeGroup[] + */ + private function processDoctrineAnnotationClasses(PhpDocInfo $phpDocInfo, array $uses): array + { + if ($phpDocInfo->getPhpDocNode()->children === []) { + return []; + } + + $doctrineTagAndAnnotationToAttributes = []; + $doctrineTagValueNodes = []; + foreach ($phpDocInfo->getPhpDocNode()->children as $phpDocChildNode) { + if (! $phpDocChildNode instanceof PhpDocTagNode) { + continue; + } + + if (! $phpDocChildNode->value instanceof DoctrineAnnotationTagValueNode) { + continue; + } + + $doctrineTagValueNode = $phpDocChildNode->value; + $annotationToAttribute = $this->matchAnnotationToAttribute($doctrineTagValueNode); + if (! $annotationToAttribute instanceof AnnotationToAttribute) { + continue; + } + + // Fix the missing leading slash in most of the wild use cases + if (str_starts_with($doctrineTagValueNode->identifierTypeNode->name, '@TYPO3\CMS')) { + $doctrineTagValueNode->identifierTypeNode->name = str_replace( + '@TYPO3\CMS', + '@\\TYPO3\CMS', + $doctrineTagValueNode->identifierTypeNode->name + ); + } + + $doctrineTagAndAnnotationToAttributes[] = new DoctrineTagAndAnnotationToAttribute( + $doctrineTagValueNode, + $annotationToAttribute + ); + $doctrineTagValueNodes[] = $doctrineTagValueNode; + } + + $attributeGroups = $this->attrGroupsFactory->create($doctrineTagAndAnnotationToAttributes, $uses); + if ($this->phpAttributeAnalyzer->hasRemoveArrayState($attributeGroups)) { + return []; + } + + foreach ($doctrineTagValueNodes as $doctrineTagValueNode) { + $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $doctrineTagValueNode); + } + + return $attributeGroups; + } + + private function matchAnnotationToAttribute( + DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode + ): ?AnnotationToAttribute { + foreach ($this->annotationsToAttributes as $annotationToAttribute) { + if (! $doctrineAnnotationTagValueNode->hasClassName($annotationToAttribute->getTag())) { + continue; + } + + return $annotationToAttribute; + } + + return null; + } +} diff --git a/tests/Issues/Issue9388/config/configured_rule.php b/tests/Issues/Issue9388/config/configured_rule.php new file mode 100644 index 00000000000..b40682b84a8 --- /dev/null +++ b/tests/Issues/Issue9388/config/configured_rule.php @@ -0,0 +1,27 @@ +autotagInterface(AttributeDecoratorInterface::class); + $rectorConfig->singleton(ValidateAttributeDecorator::class); + $rectorConfig->when(AttributeDecorator::class)->needs('$decorators')->giveTagged( + AttributeDecoratorInterface::class + ); + + $rectorConfig->importNames(false, false); + $rectorConfig->phpVersion(PhpVersionFeature::ATTRIBUTES); + + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ + 'TYPO3\CMS\Extbase\Mvc\Web\Request' => 'TYPO3\CMS\Extbase\Mvc\Request', + ]); + $rectorConfig->rule(ExtbaseAnnotationToAttributeRector::class); +}; From 7815bcd65a83ade75e542b095c1e0d70a8b5be6e Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 26 Sep 2025 16:47:55 +0700 Subject: [PATCH 2/6] Closes #7330 --- rules/CodingStyle/Node/NameImporter.php | 2 +- .../PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php | 5 +++-- src/PostRector/Collector/UseNodesToAddCollector.php | 1 - .../PhpDocParser/IdentifierPhpDocTypeMapper.php | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/rules/CodingStyle/Node/NameImporter.php b/rules/CodingStyle/Node/NameImporter.php index 3532a597ab9..ed8848c4bcf 100644 --- a/rules/CodingStyle/Node/NameImporter.php +++ b/rules/CodingStyle/Node/NameImporter.php @@ -138,7 +138,7 @@ private function addUseImport( FullyQualified $fullyQualified, FullyQualifiedObjectType $fullyQualifiedObjectType ): void { - if ($this->useNodesToAddCollector->hasImport($file, $fullyQualified, $fullyQualifiedObjectType)) { + if ($this->useNodesToAddCollector->hasImport($file, $fullyQualifiedObjectType)) { return; } diff --git a/src/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php b/src/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php index e40eb031bdc..152070d60e3 100644 --- a/src/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php +++ b/src/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php @@ -146,7 +146,7 @@ private function processFqnNameImport( return null; } - if ($this->shouldImport($newNode, $identifierTypeNode, $fullyQualifiedObjectType)) { + if ($this->shouldImport($file, $newNode, $identifierTypeNode, $fullyQualifiedObjectType)) { $this->useNodesToAddCollector->addUseImport($fullyQualifiedObjectType); $this->hasChanged = true; @@ -157,6 +157,7 @@ private function processFqnNameImport( } private function shouldImport( + File $file, IdentifierTypeNode $newNode, IdentifierTypeNode $identifierTypeNode, FullyQualifiedObjectType $fullyQualifiedObjectType @@ -181,7 +182,7 @@ private function shouldImport( $firstPath = Strings::before($identifierTypeNode->name, '\\' . $newNode->name); if ($firstPath === null) { - return true; + return ! $this->useNodesToAddCollector->hasImport($file, $fullyQualifiedObjectType); } if ($firstPath === '') { diff --git a/src/PostRector/Collector/UseNodesToAddCollector.php b/src/PostRector/Collector/UseNodesToAddCollector.php index 43f99fa49af..720ea638e59 100644 --- a/src/PostRector/Collector/UseNodesToAddCollector.php +++ b/src/PostRector/Collector/UseNodesToAddCollector.php @@ -86,7 +86,6 @@ public function getUseImportTypesByNode(File $file): array public function hasImport( File $file, - FullyQualified $fullyQualified, FullyQualifiedObjectType $fullyQualifiedObjectType ): bool { $useImports = $this->getUseImportTypesByNode($file); diff --git a/src/StaticTypeMapper/PhpDocParser/IdentifierPhpDocTypeMapper.php b/src/StaticTypeMapper/PhpDocParser/IdentifierPhpDocTypeMapper.php index 2d9618ccc3b..76a64dc7db9 100644 --- a/src/StaticTypeMapper/PhpDocParser/IdentifierPhpDocTypeMapper.php +++ b/src/StaticTypeMapper/PhpDocParser/IdentifierPhpDocTypeMapper.php @@ -97,8 +97,7 @@ public function mapIdentifierTypeNode(IdentifierTypeNode $identifierTypeNode, No return new UnionType($scalarTypes); } - $identifierTypeNode->name = ltrim($identifierTypeNode->name, '@'); - $objectType = new ObjectType($identifierTypeNode->name); + $objectType = new ObjectType(ltrim($identifierTypeNode->name, '@')); } $scope = $node->getAttribute(AttributeKey::SCOPE); From 8b676a617ec49aab9ce3cc5106621a3abeaaeb87 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 26 Sep 2025 09:51:24 +0000 Subject: [PATCH 3/6] [ci-review] Rector Rectify --- .../Collector/UseNodesToAddCollector.php | 1 - .../ValidateAttributeDecorator.php | 26 +++++-------------- .../ExtbaseAnnotationToAttributeRector.php | 6 ++--- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/PostRector/Collector/UseNodesToAddCollector.php b/src/PostRector/Collector/UseNodesToAddCollector.php index 720ea638e59..867cd822996 100644 --- a/src/PostRector/Collector/UseNodesToAddCollector.php +++ b/src/PostRector/Collector/UseNodesToAddCollector.php @@ -5,7 +5,6 @@ namespace Rector\PostRector\Collector; use PhpParser\Node\Identifier; -use PhpParser\Node\Name\FullyQualified; use Rector\Application\Provider\CurrentFileProvider; use Rector\Naming\Naming\UseImportsResolver; use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType; diff --git a/tests/Issues/Issue9388/AnnotationToAttribute/ValidateAttributeDecorator.php b/tests/Issues/Issue9388/AnnotationToAttribute/ValidateAttributeDecorator.php index 6f59166defe..4bc3e2825b0 100644 --- a/tests/Issues/Issue9388/AnnotationToAttribute/ValidateAttributeDecorator.php +++ b/tests/Issues/Issue9388/AnnotationToAttribute/ValidateAttributeDecorator.php @@ -14,24 +14,10 @@ use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\PhpParser\Node\Value\ValueResolver; -final class ValidateAttributeDecorator implements AttributeDecoratorInterface +final readonly class ValidateAttributeDecorator implements AttributeDecoratorInterface { - /** - * @readonly - */ - private ValueResolver $valueResolver; - - /** - * @readonly - */ - private StringClassNameToClassConstantRector $stringClassNameToClassConstantRector; - - public function __construct( - ValueResolver $valueResolver, - StringClassNameToClassConstantRector $stringClassNameToClassConstantRector - ) { - $this->valueResolver = $valueResolver; - $this->stringClassNameToClassConstantRector = $stringClassNameToClassConstantRector; + public function __construct(private ValueResolver $valueResolver, private StringClassNameToClassConstantRector $stringClassNameToClassConstantRector) + { } public function supports(string $phpAttributeName): bool @@ -41,7 +27,7 @@ public function supports(string $phpAttributeName): bool public function decorate(Attribute $attribute): void { - $newArguments = new Array_(); + $array = new Array_(); foreach ($attribute->args as $arg) { $key = $arg->name instanceof Identifier ? new String_($arg->name->toString()) : new String_('validator'); @@ -59,9 +45,9 @@ public function decorate(Attribute $attribute): void $value = $arg->value; } - $newArguments->items[] = new ArrayItem($value, $key); + $array->items[] = new ArrayItem($value, $key); } - $attribute->args = [new Arg($newArguments)]; + $attribute->args = [new Arg($array)]; } } diff --git a/tests/Issues/Issue9388/Rule/ExtbaseAnnotationToAttributeRector.php b/tests/Issues/Issue9388/Rule/ExtbaseAnnotationToAttributeRector.php index dc616a4231f..8ae422de50e 100644 --- a/tests/Issues/Issue9388/Rule/ExtbaseAnnotationToAttributeRector.php +++ b/tests/Issues/Issue9388/Rule/ExtbaseAnnotationToAttributeRector.php @@ -32,7 +32,7 @@ final class ExtbaseAnnotationToAttributeRector extends AbstractRector implements /** * @var AnnotationToAttribute[] */ - private array $annotationsToAttributes; + private readonly array $annotationsToAttributes; public function __construct( private readonly AttributeDecorator $attributeDecorator, @@ -98,8 +98,8 @@ public function refactor(Node $node): ?Node $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node); - foreach ($annotationAttributeGroups as $attributeGroup) { - foreach ($attributeGroup->attrs as $attr) { + foreach ($annotationAttributeGroups as $annotationAttributeGroup) { + foreach ($annotationAttributeGroup->attrs as $attr) { $phpAttributeName = $attr->name->getAttribute(AttributeKey::PHP_ATTRIBUTE_NAME); $this->attributeDecorator->decorate($phpAttributeName, $attr); } From 56be8f09bc48925889d564978a88172b2caaf5ce Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 26 Sep 2025 16:54:29 +0700 Subject: [PATCH 4/6] Fix phpstan --- .../Fixture/skip_parent_class.php | 24 +++++++++++++++++++ tests/Issues/Issue9388/Issue9388Test.php | 4 ---- .../AttributeDecorator.php | 2 +- .../AttributeDecoratorInterface.php | 2 +- .../ValidateAttributeDecorator.php | 2 +- .../ExtbaseAnnotationToAttributeRector.php | 4 ++-- .../Issue9388/config/configured_rule.php | 9 +++---- 7 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 rules-tests/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector/Fixture/skip_parent_class.php rename tests/Issues/Issue9388/{ => Source}/AnnotationToAttribute/AttributeDecorator.php (88%) rename tests/Issues/Issue9388/{ => Source}/AnnotationToAttribute/AttributeDecoratorInterface.php (76%) rename tests/Issues/Issue9388/{ => Source}/AnnotationToAttribute/ValidateAttributeDecorator.php (96%) rename tests/Issues/Issue9388/{ => Source}/Rule/ExtbaseAnnotationToAttributeRector.php (97%) diff --git a/rules-tests/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector/Fixture/skip_parent_class.php b/rules-tests/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector/Fixture/skip_parent_class.php new file mode 100644 index 00000000000..09913844ae3 --- /dev/null +++ b/rules-tests/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector/Fixture/skip_parent_class.php @@ -0,0 +1,24 @@ +getSome() + 5; + } +} + +abstract class AbstractParentClass +{ + /** + * @var int + */ + private $value = 100; + + public function getSome() + { + return $this->value; + } +} diff --git a/tests/Issues/Issue9388/Issue9388Test.php b/tests/Issues/Issue9388/Issue9388Test.php index 0745efa91ab..b02fa9d8639 100644 --- a/tests/Issues/Issue9388/Issue9388Test.php +++ b/tests/Issues/Issue9388/Issue9388Test.php @@ -17,10 +17,6 @@ final class Issue9388Test extends AbstractRectorTestCase #[DataProvider('provideData')] public function test(string $filePath): void { - if (PHP_VERSION_ID < PhpVersionFeature::ATTRIBUTES) { - $this->markTestSkipped('Do not execute'); - } - $this->doTestFile($filePath); } diff --git a/tests/Issues/Issue9388/AnnotationToAttribute/AttributeDecorator.php b/tests/Issues/Issue9388/Source/AnnotationToAttribute/AttributeDecorator.php similarity index 88% rename from tests/Issues/Issue9388/AnnotationToAttribute/AttributeDecorator.php rename to tests/Issues/Issue9388/Source/AnnotationToAttribute/AttributeDecorator.php index 92674fba7a6..69355db3c5c 100644 --- a/tests/Issues/Issue9388/AnnotationToAttribute/AttributeDecorator.php +++ b/tests/Issues/Issue9388/Source/AnnotationToAttribute/AttributeDecorator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\Tests\Issues\Issue9388\AnnotationToAttribute; +namespace Rector\Tests\Issues\Issue9388\Source\AnnotationToAttribute; use PhpParser\Node\Attribute; diff --git a/tests/Issues/Issue9388/AnnotationToAttribute/AttributeDecoratorInterface.php b/tests/Issues/Issue9388/Source/AnnotationToAttribute/AttributeDecoratorInterface.php similarity index 76% rename from tests/Issues/Issue9388/AnnotationToAttribute/AttributeDecoratorInterface.php rename to tests/Issues/Issue9388/Source/AnnotationToAttribute/AttributeDecoratorInterface.php index bd4ebe11d98..77af25249fa 100644 --- a/tests/Issues/Issue9388/AnnotationToAttribute/AttributeDecoratorInterface.php +++ b/tests/Issues/Issue9388/Source/AnnotationToAttribute/AttributeDecoratorInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\Tests\Issues\Issue9388\AnnotationToAttribute; +namespace Rector\Tests\Issues\Issue9388\Source\AnnotationToAttribute; use PhpParser\Node\Attribute; diff --git a/tests/Issues/Issue9388/AnnotationToAttribute/ValidateAttributeDecorator.php b/tests/Issues/Issue9388/Source/AnnotationToAttribute/ValidateAttributeDecorator.php similarity index 96% rename from tests/Issues/Issue9388/AnnotationToAttribute/ValidateAttributeDecorator.php rename to tests/Issues/Issue9388/Source/AnnotationToAttribute/ValidateAttributeDecorator.php index 4bc3e2825b0..22d90e80983 100644 --- a/tests/Issues/Issue9388/AnnotationToAttribute/ValidateAttributeDecorator.php +++ b/tests/Issues/Issue9388/Source/AnnotationToAttribute/ValidateAttributeDecorator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\Tests\Issues\Issue9388\AnnotationToAttribute; +namespace Rector\Tests\Issues\Issue9388\Source\AnnotationToAttribute; use PhpParser\Node\Arg; use PhpParser\Node\ArrayItem; diff --git a/tests/Issues/Issue9388/Rule/ExtbaseAnnotationToAttributeRector.php b/tests/Issues/Issue9388/Source/Rule/ExtbaseAnnotationToAttributeRector.php similarity index 97% rename from tests/Issues/Issue9388/Rule/ExtbaseAnnotationToAttributeRector.php rename to tests/Issues/Issue9388/Source/Rule/ExtbaseAnnotationToAttributeRector.php index 8ae422de50e..0f145bbeefe 100644 --- a/tests/Issues/Issue9388/Rule/ExtbaseAnnotationToAttributeRector.php +++ b/tests/Issues/Issue9388/Source/Rule/ExtbaseAnnotationToAttributeRector.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\Tests\Issues\Issue9388\Rule; +namespace Rector\Tests\Issues\Issue9388\Source\Rule; use PhpParser\Node; use PhpParser\Node\AttributeGroup; @@ -21,7 +21,7 @@ use Rector\Php80\ValueObject\AnnotationToAttribute; use Rector\Php80\ValueObject\DoctrineTagAndAnnotationToAttribute; use Rector\Rector\AbstractRector; -use Rector\Tests\Issues\Issue9388\AnnotationToAttribute\AttributeDecorator; +use Rector\Tests\Issues\Issue9388\Source\AnnotationToAttribute\AttributeDecorator; use Rector\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; diff --git a/tests/Issues/Issue9388/config/configured_rule.php b/tests/Issues/Issue9388/config/configured_rule.php index b40682b84a8..9f59172b0bd 100644 --- a/tests/Issues/Issue9388/config/configured_rule.php +++ b/tests/Issues/Issue9388/config/configured_rule.php @@ -4,10 +4,10 @@ use Rector\Config\RectorConfig; use Rector\Renaming\Rector\Name\RenameClassRector; -use Rector\Tests\Issues\Issue9388\AnnotationToAttribute\AttributeDecorator; -use Rector\Tests\Issues\Issue9388\AnnotationToAttribute\AttributeDecoratorInterface; -use Rector\Tests\Issues\Issue9388\AnnotationToAttribute\ValidateAttributeDecorator; -use Rector\Tests\Issues\Issue9388\Rule\ExtbaseAnnotationToAttributeRector; +use Rector\Tests\Issues\Issue9388\Source\AnnotationToAttribute\AttributeDecorator; +use Rector\Tests\Issues\Issue9388\Source\AnnotationToAttribute\AttributeDecoratorInterface; +use Rector\Tests\Issues\Issue9388\Source\AnnotationToAttribute\ValidateAttributeDecorator; +use Rector\Tests\Issues\Issue9388\Source\Rule\ExtbaseAnnotationToAttributeRector; use Rector\ValueObject\PhpVersionFeature; return static function (RectorConfig $rectorConfig): void { @@ -24,4 +24,5 @@ 'TYPO3\CMS\Extbase\Mvc\Web\Request' => 'TYPO3\CMS\Extbase\Mvc\Request', ]); $rectorConfig->rule(ExtbaseAnnotationToAttributeRector::class); + $rectorConfig->phpVersion(PhpVersionFeature::ATTRIBUTES); }; From 965b2fa96ff0c242c78e2f88cd09d5177bdb2ce2 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 26 Sep 2025 16:57:05 +0700 Subject: [PATCH 5/6] clean up fixture --- .../Fixture/skip_parent_class.php | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 rules-tests/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector/Fixture/skip_parent_class.php diff --git a/rules-tests/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector/Fixture/skip_parent_class.php b/rules-tests/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector/Fixture/skip_parent_class.php deleted file mode 100644 index 09913844ae3..00000000000 --- a/rules-tests/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector/Fixture/skip_parent_class.php +++ /dev/null @@ -1,24 +0,0 @@ -getSome() + 5; - } -} - -abstract class AbstractParentClass -{ - /** - * @var int - */ - private $value = 100; - - public function getSome() - { - return $this->value; - } -} From 52444ecdcbea2b3cf54cf42533c9f9e8288a5fca Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 26 Sep 2025 09:57:19 +0000 Subject: [PATCH 6/6] [ci-review] Rector Rectify --- tests/Issues/Issue9388/Issue9388Test.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Issues/Issue9388/Issue9388Test.php b/tests/Issues/Issue9388/Issue9388Test.php index b02fa9d8639..07b6c0a3445 100644 --- a/tests/Issues/Issue9388/Issue9388Test.php +++ b/tests/Issues/Issue9388/Issue9388Test.php @@ -7,7 +7,6 @@ use Iterator; use PHPUnit\Framework\Attributes\DataProvider; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\ValueObject\PhpVersionFeature; /** * @see https://github.com/rectorphp/rector/issues/9388