-
-
Notifications
You must be signed in to change notification settings - Fork 861
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
ReflectionClass::newInstanceArgs() - error on argument type #8679
Comments
this might be as simple as fixing the you could give it a try and create a PR, and corresponding tests |
Great, I saw it but wasn't sure it was the right one to make changes to. I didn't go deep in PHPStan internals. I'll try to do the pull request. |
Fwiw, in psalm they seem to fix the same issue atm: |
Before changing the code, I was doing a little reflection: Changing the data type should not break the compatibility if PHPStan being used to analyze php code for a version prior to PHP 8.0, I did some tries and i saw that using an associative array with
Locally I have updated the stub, and the tool seem work as expected on my code. I have to identify how to test this change and update unit tests. |
It seems to be doing just that, I hadn't thought to check the other similar tools. |
Fixed: phpstan/phpstan-src#2176 |
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. |
Bug report
PHPStan version:
1.9.8
Analyzing a piece of code with
ReflectionClass::newInstanceArgs()
, PHPStan report an error about the type of the method argument.newInstanceArgs
expects an array withint
keys andmixed
values,array<int, mixed>
but since PHP 8.0 it is possible to use named arguments, in this case the type of the array keys isstring
and a typearray<string, mixed>
should be also valid.Code snippet that reproduces the problem
I tested a piece of code both in PHPStan Playground and in 3v4l.org
https://phpstan.org/r/ddada382-718d-4dd0-b495-b545ddddb151
https://3v4l.org/TAJHT
In 3v4l.org the code snippet works as expected.
Expected output
No errors instead of the one at line 27.
Did PHPStan help you today? Did it make you happy in any way?
I found years old bugs on my code thanks to this tool!
The text was updated successfully, but these errors were encountered: