Skip to content

Opinion on removing name dependency from Class__::isAnonymous() #1018

@tscni

Description

@tscni

Hi

This has been brought up before partially (#554).
PHPStan gives anonymous class nodes a name to generalize behavior between anonymous and regular classes.
As pointed out before, this does of course break PhpParser\Node\Stmt\Class_::isAnonymous().

We can resolve this by extending Class_ and overriding the method to always return true. (as implemented here phpstan/phpstan-src#3343), but it feels a bit cumbersome to do.

So here I'm mainly wondering what your opinion is on changing Class_::isAnoynmous() to use e.g. a new "is anonymous" flag or similar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions