Skip to content

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
@tscni tscni force-pushed the fix/class-is-anonymous branch from 5c723eb to b8a841b Compare August 22, 2024 22:37
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.

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.

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
@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

2 participants