We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@template
array-key
When I define a generic key type as @template TKey of array-key, PHPStan doesn't seem to want to combine it with other types via @return:
@template TKey of array-key
@return
/** * @template TOtherKey of array-key * @template TOtherValue * * @param iterable<TOtherKey, TOtherValue> ...$iterables * @return self<TKey|TOtherKey, TValue|TOtherValue> */ function merge(iterable ...$iterables): self;
Calling this method does not combine TKey with TOtherKey - it just keeps it as TKey: https://phpstan.org/r/31d3d483-7e0c-4239-8c88-67cf00c807ae
TKey
TOtherKey
This seems to work fine in Psalm: https://psalm.dev/r/8671dd080b
Using string|int instead of array-key seems to "fix" this: https://phpstan.org/r/edf51290-fe27-4024-b07d-3e7c327e5825
string|int
And so does removing the type entirely: https://phpstan.org/r/ff4f41fa-691c-4fe4-8837-ef0ec2179c04
https://phpstan.org/r/31d3d483-7e0c-4239-8c88-67cf00c807ae
-Dumped type: Map<string, bool|int> +Dumped type: Map<int|string, bool|int> -Dumped type: Map<string, bool|int|stdClass> +Dumped type: Map<int|string, bool|int|stdClass>
No response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Bug report
When I define a generic key type as
@template TKey of array-key
, PHPStan doesn't seem to want to combine it with other types via@return
:Calling this method does not combine
TKey
withTOtherKey
- it just keeps it asTKey
:https://phpstan.org/r/31d3d483-7e0c-4239-8c88-67cf00c807ae
This seems to work fine in Psalm: https://psalm.dev/r/8671dd080b
Using
string|int
instead ofarray-key
seems to "fix" this:https://phpstan.org/r/edf51290-fe27-4024-b07d-3e7c327e5825
And so does removing the type entirely:
https://phpstan.org/r/ff4f41fa-691c-4fe4-8837-ef0ec2179c04
Code snippet that reproduces the problem
https://phpstan.org/r/31d3d483-7e0c-4239-8c88-67cf00c807ae
Expected output
Did PHPStan help you today? Did it make you happy in any way?
No response
The text was updated successfully, but these errors were encountered: