Skip to content

Error when calling an impure constructor defined in the parent class of an anonymous class #13698

@takaram

Description

@takaram

Bug report

new Foo(); on a separate line does not report an error when Foo's constructor is impure or throws an exception.

However, new class() extends Foo {}; gives an error: Expression "new class extends \Foo…" on a separate line does not do anything.

In the code snippet below, uncommenting line 18-21 removes the error.

Code snippet that reproduces the problem

https://phpstan.org/r/f73606f1-2de1-4e6a-950b-c2058ba08c87

Expected output

No error

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions