-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
[TypeDeclaration] Handle skipped by file path on DeclareStrictTypesRector due to use beforeTraverse() #5191
Conversation
Fixed 🎉 /cc @kenjis |
All checks have passed 🎉 @TomasVotruba it is ready for review. |
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.
@samsonasik thank you!
parent::beforeTraverse($nodes); | ||
|
||
$filePath = $this->file->getFilePath(); | ||
if ($this->skipper->shouldSkipElementAndFilePath(self::class, $filePath)) { | ||
return null; | ||
} |
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 should be moved to AbstractRector::beforeTraverse()
or similar, as rector rule itself should not decide about the sip.
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.
It can't, as AbstractRector::beforeTraverse()
on setup File object, and re-called early in current parent::beforeTraverse()
, moving to AbstractRector will require parent::beforeTraverse()
to not called early, but after.
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.
I see. Let's go for it now then.
Bbut in case more rules will need the skip fix, we'll have to move it to single place outside specific rules.
Thank you 👍 |
@kenjis this is for bug you found on CodeIgniter PR:
declare(strict_types=1)
codeigniter4/CodeIgniter4#8072 (comment)which
DeclareStrictTypesRector
due to usebeforeTraverse()
instead ofenterNode()
, while onAbstractRector
, checking skip is byenterNode()
so it overlapped.