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

Remove PARENT_NODE from CatchExceptionNameMatchingTypeRector #3929

Merged
merged 1 commit into from
May 22, 2023

Conversation

TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented May 22, 2023

@TomasVotruba TomasVotruba merged commit 112e490 into main May 22, 2023
@TomasVotruba TomasVotruba deleted the tv-less-parent-15 branch May 22, 2023 14:04
{
if (rand(0, 1)) {
try {
} catch (SomeException $typoException) {
Copy link
Member

Choose a reason for hiding this comment

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

this PR cause a bug:

-            } catch (SomeException $typoException) {
+            } catch (SomeException $someException) {

which $typoException is variable that exists after jump if, to skip it, StmtsAwareInterface can be replaced with direct ClassMethod, Function_, Namespace_, FileWithoutNamespace, Closure which on top.

Copy link
Member

Choose a reason for hiding this comment

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

I will create a PR for it :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Nested try/catch should be handled too.

I think this would cause a bug even for those on top. As we do not handle rename after.

If you find a better way without parent node, go for it 👍 Maybe custom node traversers is needed.

Copy link
Member

Choose a reason for hiding this comment

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

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.

2 participants