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

Repair PhpParser\Node\Stmt\Class_::isAnonymous() #3343

Merged
merged 3 commits into from
Aug 23, 2024

Conversation

tscni
Copy link
Contributor

@tscni tscni commented Aug 22, 2024

As proposed here: #3328 (comment)

@tscni tscni changed the base branch from 1.12.x to 1.11.x August 22, 2024 22:36
Copy link
Contributor Author

@tscni tscni left a comment

Choose a reason for hiding this comment

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

This should work, but I'm slightly concerned regarding backward compatibility of node attributes.

@@ -27,10 +27,20 @@ public function enterNode(Node $node): ?Node
return null;
}

$node->setAttribute(self::ATTRIBUTE_ANONYMOUS_CLASS, true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In theory this isn't covered by the backward compatibility promise, right?
Even so, the removal of this would cause some breakages (see e.g. mglaman/phpstan-drupal#195)

Copy link
Member

Choose a reason for hiding this comment

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

Let's keep the attribute but don't use it ourselves anywhere anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I opted against keeping the constant since it's not meant to be reused.

@@ -27,10 +27,20 @@ public function enterNode(Node $node): ?Node
return null;
}

$node->setAttribute(self::ATTRIBUTE_ANONYMOUS_CLASS, true);
Copy link
Member

Choose a reason for hiding this comment

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

Let's keep the attribute but don't use it ourselves anywhere anymore.

@ondrejmirtes ondrejmirtes merged commit 03626d9 into phpstan:1.11.x Aug 23, 2024
453 of 463 checks passed
@ondrejmirtes
Copy link
Member

Thank you! Btw I wouldn't bother PHP-Parser with this, it's a niche edge case we've already solved, no need to change the underlying library.

@tscni tscni deleted the fix/class-is-anonymous branch August 25, 2024 15:57
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