-
-
Notifications
You must be signed in to change notification settings - Fork 431
Add example for issue #9388 #7330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| { | ||
| /** | ||
| * @var string | ||
| * @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as I already stated in your other PR, using namespaced annotation inside namespace will become; namespace + annotation. If you need fqcn without \\, add:
use TYPO3;in use statements or create rule/script init that add \\ prefix early to become;
@\TYPO3\...
Just because in one condition it works, in another condition not works, doesn't mean the original annotation is valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just because in one condition it works, in another condition not works, doesn't mean the original annotation is valid.
The question is why is this the case? I know this needs some debugging but there must be something going on why there is a difference. If we find the place, I can provide a fix. It's just very difficult to understand the php doc parsing. Maybe @TomasVotruba has an idea as he originally created the better doc block parser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how PHP uses namespaces. Either add use TYPO; or use \\ to FQN the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we only use https://github.com/phpstan/phpdoc-parser here with a bit of wrapping. So the cause might be there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how PHP uses namespaces. Either add use TYPO; or use \ to FQN the class.
This was the official TYPO3 way of annotating. I can't just tell everybody to adjust their code. That's why I built a rule to migrate that to a native php attribute. The transformation to a php attribute also works as long as there is no @var string annotation. For some reason this additional annotation is causing problems and I'm trying to figure out why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That can be behaviour of PHPStan\Analyser\NameScope that unrelated to Rector.
The best way is to add use TYPO3 in your use statements.
For your usecase in case you still want the way it is, you probably needs to implements your own PhpDocNodeDecoratorInterface instance, and decorate resolved_class attribute, special for TYPO3 annotation, then you can replace by its resolved_class value.
rector-src/src/BetterPhpDocParser/Contract/PhpDocParser/PhpDocNodeDecoratorInterface.php
Lines 10 to 13 in d64f8d8
| interface PhpDocNodeDecoratorInterface | |
| { | |
| public function decorate(PhpDocNode $phpDocNode, Node $phpNode): void; | |
| } |
see examples on existing decorator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I'm gonna try this out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simonschaufi I got it, it seems needs tweak on IdentifierPhpDocTypeMapper to not replace the existing IdentifierTypeNode on visit, then verify on auto import handling docblock, see PR:
* Add example for issue #9388 * Closes #7330 * [ci-review] Rector Rectify * Fix phpstan * clean up fixture * [ci-review] Rector Rectify --------- Co-authored-by: Simon Schaufelberger <simonschaufi@users.noreply.github.com> Co-authored-by: GitHub Action <actions@github.com>
No description provided.