New issue
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
False Positive with array declaration & array_merge #1516
Comments
Please follow the instructions and add a link to phpstan.org reproduction. |
Link added for the test. Thank you very much. |
The |
All right, thank you very much for the quick answer :) |
Please don’t close it, it’s still a valid bug waiting for a solution 😊 |
I have a different false positive here: // Returns array as documented with keys that each contain an assoc array
$modules = static::releaseTypedModuleList($releaseGroup);
return $modules['major'] + $modules['minor'] + $modules['patch']; PHPStan wrongly thinks too much here:
Those are nested arrays, and the + operation on the assoc arrays are valid. Manually applying casting seems to workaround it for now:
|
@dereuromark You should check what PHPStan thinks that |
I argue from the other direction To be clear: + operator is not only for int/float, but also valid for array merge op. |
PHPStan knows that Why it thinks in your case that it's just |
https://phpstan.org/r/7d71e14b-2165-4dd2-b25f-89228a4dfe8d shows it |
Yeah, so this is a separate bug. It shows that |
This one is fixed already. |
Closes phpstan/phpstan#5893 Closes phpstan/phpstan#6070 Closes phpstan/phpstan#5869 Closes phpstan/phpstan#6212 Closes phpstan/phpstan#6262 Closes phpstan/phpstan#6266 Closes phpstan/phpstan#6023 Closes phpstan/phpstan#6108 Closes phpstan/phpstan#6020 Closes phpstan/phpstan#1746 Closes phpstan/phpstan#1516 Closes phpstan/phpstan#6174 Closes phpstan/phpstan#6112 Closes phpstan/phpstan#5749 Closes phpstan/phpstan#5969 Closes phpstan/phpstan#5295 Closes phpstan/phpstan#5675 Closes phpstan/phpstan#5369 Closes phpstan/phpstan#6699 Closes phpstan/phpstan#6505
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
phpstan with array_merge throws an error while declaring a new array;
This throws
But this should not show 'array|string' if I am correct !
Here is the link to the test : https://phpstan.org/r/ec3f94a5a68d29d017491a320190ca99
Thank you
Good day
The text was updated successfully, but these errors were encountered: