Skip to content

ReflectionClass constructor, string given #2808

@odan

Description

@odan

Bug report

PHPStan version: 12.3.0

Creating an ReflectionClass instance within a class method generated the following error:

Parameter #1 $argument of class ReflectionClass constructor expects 
class-string<T of object>|T of object, string given. |

Example: https://phpstan.org/r/b99b2fa6-f633-4cb9-b034-85fe69e5fb2e

or

Parameter #1 $argument of class ReflectionClass constructor 
expects |class-string<>, string given. |

Example: https://phpstan.org/r/1bf6b512-f082-4234-a344-c9d9711e0dcd

But if I pass a string directly, with a valid class name, it doesn't triggers an error:

Example: https://phpstan.org/r/68fef600-29f9-4775-aee2-8bb35c358224

Expected output

No error, because $argument is either a string containing the name of the class to reflect, or an object.

https://www.php.net/manual/en/reflectionclass.construct.php

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions