Skip to content

[TypeDeclaration] Handle skipped by file path on DeclareStrictTypesRector due to use beforeTraverse()#5191

Merged
TomasVotruba merged 4 commits intomainfrom
handle-skipped-by-file-path
Oct 23, 2023
Merged

[TypeDeclaration] Handle skipped by file path on DeclareStrictTypesRector due to use beforeTraverse()#5191
TomasVotruba merged 4 commits intomainfrom
handle-skipped-by-file-path

Conversation

@samsonasik
Copy link
Copy Markdown
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
Copy Markdown
Member Author

Fixed 🎉 /cc @kenjis

@samsonasik
Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@TomasVotruba TomasVotruba deleted the handle-skipped-by-file-path branch October 23, 2023 07:47
@TomasVotruba
Copy link
Copy Markdown
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