🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Unexpected error when using ReflectionClass::newInstance() #15032

Description

@eliashaeussler

Bug report

As can be seen in below's code snippet, using ReflectionObject::newInstance() (inherited from ReflectionClass::newInstance()) with a template type leads to an error:

Function should return T of object but returns object

Code snippet that reproduces the problem

https://phpstan.org/r/387d0287-c0cb-4aca-86bf-13c4329df80b

Expected output

I wouldn't expect an error here, because the reflection was done on a specific object. Calling newInstance should return a new instance of this exact class (or fail).

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