Skip to content

Same generics won't match depending on the field type #13722

@nickkadutskyi

Description

@nickkadutskyi

Bug report

Here is playground that won't work: https://phpstan.org/r/cf4cbe40-30fa-4a96-98f4-6a7a39a6fa8e
And here is a similar playground that does work: https://phpstan.org/r/2d72088d-e2bc-4e37-8970-4869e49db476

The difference in the template definition for a generic type:
If I do this:

    /**
	 * @param I2<array{
	 *    b: array<string>|false|null, 
	 *    c: string|false|null
	 *  }> $a2
	 */

It doesn't work but if I remove b field or remove array from it it does work:

    /**
     * @param I2<array{
	 *    c: string|false|null
	 *  }> $a2
	 */
    /**
     * @param I2<array{
     *    b: false|null, 
	 *    c: string|false|null
	 *  }> $a2
	 */

Code snippet that reproduces the problem

https://phpstan.org/r/cf4cbe40-30fa-4a96-98f4-6a7a39a6fa8e

Expected output

There should be no issues as in this similar example:
https://phpstan.org/r/2d72088d-e2bc-4e37-8970-4869e49db476

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

It's actually great, first time stumbling on an issues.

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