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
Union Type + Nullable yields "Expects TEntity(A|B)|null, TEntity(A|B)|null given" #5591
Comments
Adding my reproduction I've created for #5677 (I think it's a bit simpler): |
I also have some trouble with generics and |
I think I'm running into the same issue as I'm trying to use:
https://phpstan.org/r/90499164-0265-4b6a-89de-b311ddcb82c4 The
A more simpler usecase is: https://phpstan.org/r/9e0eebc8-a3e5-4cc9-9fbf-e182e71fdd93 /cc @ondrejmirtes as it seems to correct analyzed can the |
@alexander-schranz After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-18: PHPDoc tag @template T for method HelloWorld::getEffectiveDimensionAttributes() with bound type null is not supported.
+No errors |
@alexander-schranz After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-12: PHPDoc tag @template T for method HelloWorld::getEffectiveDimensionAttributes() with bound type null is not supported.
+No errors |
Thank you @ondrejmirtes and @arnaud-lb 👍 |
Thank you! |
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
Hello! I'm having a counterintuitive moment after my recent PHPStan update where I'm getting an error message that reads out like:
Basically, it's saying it expected, and was given, the exact same type. It shouldn't be an error at all.
I think it's getting tripped up by the
TEntity as A|B
declaration, then later havingTEntity|null
being defined as a method parameter.Was able to reproduce this via the web PHPStan tester. Can verify via my own local code that the same issue isn't present in 0.12.96 but is present in both 0.12.97 and 0.12.98.
Code snippet that reproduces the problem
https://phpstan.org/r/cc421f16-0749-407d-80ac-e05e7624d3f7
Expected output
No issues with the sample code.
Did PHPStan help you today? Did it make you happy in any way?
PHPStan helps me every day! It's a wonderful tool and I'm proud to be one of its supporters. <3
The text was updated successfully, but these errors were encountered: