Skip to content

Empty string and generics union type parameter issue #7562

@koriym

Description

@koriym

Bug report

Empty string and generics union type parameter does not accept an empty string.

''|class-string union type parameter accepts empty-string, but not with ''|class-string<T> parameter.

Code snippet that reproduces the problem

/**
 * @param ''|class-string<T> $p
 * @template T of object
 */
function ng($p): void
{
}

ng('');

Parameter #1 $p of function ng expects class-string<>, string given.

https://phpstan.org/r/c4e8c2a7-59a6-4863-94e4-48b0a02b7af3

Expected output

No error.

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

It always helps. Arigato!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions