Skip to content

Classes with the same name as PHP's lead to confusing errors #11303

@jchaffraix

Description

@jchaffraix

Bug report

See the attached reproduction.

The main issue is due to reusing PHP's Pool name. Here are the 2 errors:

Class Pool constructor invoked with 1 parameter, 2-3 required.
Parameter #1 $size of class Pool constructor expects int, string given.

What's not clear is that those refer to PHP's Pool class and not the one that is in the same file (which is what the PHP interpreter uses).

At minimal, a warning would be useful to let the user know that there is ambiguity on the name.

Code snippet that reproduces the problem

https://phpstan.org/r/e061b7f3-945e-48e1-b401-11287f3d3015

Expected output

Ideally: no error.

Could live with a warning that we have 2 classes with the same name.

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

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions