Skip to content

Conversation

@simonschaufi
Copy link
Contributor

@simonschaufi simonschaufi changed the title Add example for issue rectorphp/rector/issues/9388 Add example for issue 9388 Sep 24, 2025
@simonschaufi
Copy link
Contributor Author

simonschaufi commented Sep 24, 2025

If you run the RenameClassRector before the rule, it's broken. If you run it after the rule, it works so there must be something going on with the doc block in RenameClassRector that breaks.

@samsonasik
Copy link
Member

samsonasik commented Sep 25, 2025

I tried this locally, and this is expected :), when you are inner namespace without \\ prefix, you define:

namespace Rector\Tests\Issues\Issue9388\Fixture;

/** @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty") */

The type detected is namespace + value of @, so it become a non-existing object type:

Rector\Tests\Issues\Issue9388\Fixture\TYPO3\CMS\Extbase\Annotation\Validate;

If you want to apply it, ensure the TYPO is in the use statement, eg:

use TYPO;

so it will correctly detect it :)

@samsonasik samsonasik closed this Sep 25, 2025
Comment on lines +145 to +151
if (str_starts_with($doctrineTagValueNode->identifierTypeNode->name, '@TYPO3\CMS')) {
$doctrineTagValueNode->identifierTypeNode->name = str_replace(
'@TYPO3\CMS',
'@\\TYPO3\CMS',
$doctrineTagValueNode->identifierTypeNode->name
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why when you flip the rule, the rule is "working", while actually invalid, as the original namespaced name is current namespace + value identifier if no \\ prefix, so you're changing behaviour of valid identifier.

Add use TYPO, and you will have correct detection :)

@rectorphp rectorphp locked as resolved and limited conversation to collaborators Sep 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants