Skip to content
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

Merged
merged 4 commits into from
Oct 23, 2023

Conversation

samsonasik
Copy link
Member

@kenjis this is for bug you found on CodeIgniter PR:

which DeclareStrictTypesRector due to use beforeTraverse() instead of enterNode(), while on AbstractRector, checking skip is by enterNode() so it overlapped.

@samsonasik samsonasik marked this pull request as draft October 22, 2023 10:54
@samsonasik samsonasik marked this pull request as ready for review October 22, 2023 11:10
@samsonasik
Copy link
Member Author

Fixed 🎉 /cc @kenjis

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

Copy link

@datamweb datamweb left a comment

Choose a reason for hiding this comment

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

@samsonasik thank you!

Comment on lines 54 to +59
parent::beforeTraverse($nodes);

$filePath = $this->file->getFilePath();
if ($this->skipper->shouldSkipElementAndFilePath(self::class, $filePath)) {
return null;
}
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

@TomasVotruba TomasVotruba merged commit 6d5ffbe into main Oct 23, 2023
41 checks passed
@TomasVotruba TomasVotruba deleted the handle-skipped-by-file-path branch October 23, 2023 07:47
@TomasVotruba
Copy link
Member

Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants