-
-
Notifications
You must be signed in to change notification settings - Fork 866
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 Static property HelloWorld::$bug (WeakMap<stdClass, stdClass>) does not accept WeakMap<object, mixed>. #5551
False positive Static property HelloWorld::$bug (WeakMap<stdClass, stdClass>) does not accept WeakMap<object, mixed>. #5551
Comments
WeakMap doesn't have This is because WeakMap implements |
Oh I get it now, the bug really shouldn't be reported. The fact is that PHPStan infers the |
Any news here? 😊 |
Same issue here, also fails on dynamic property with |
another repro: https://phpstan.org/r/9cdef996-1e77-4334-bc79-1af78d5b4139 I can confirm this issue is present only when assigning into static property. |
should be easy fix |
Waiting for your PR 😊 |
Let's work on this collaboratively 😊 |
@netpok After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.0 – 8.3 (2 errors)
+PHP 8.0 – 8.3 (1 error)
==========
18: Property HelloWorld::$vm2 (WeakMap<HelloWorld, HelloWorld>) does not accept WeakMap<HelloWorld, HelloWorld>|WeakMap<object, mixed>.
-20: Parameter #1 $a of method HelloWorld::sayHello() expects HelloWorld, HelloWorld|null given.
PHP 7.2 – 7.4 (7 errors)
========== Full reportPHP 8.0 – 8.3 (1 error)
PHP 7.2 – 7.4 (7 errors)
|
Bug report
When you do something like phpstan will report "Static property HelloWorld::$bug (WeakMap<stdClass, stdClass>) does not accept WeakMap<object, mixed>", probably it must not do this (non-static property work as expected).
Code snippet that reproduces the problem
https://phpstan.org/r/c82951da-ead5-4999-a670-db23e6fb07b3
Expected output
no error
Did PHPStan help you today? Did it make you happy in any way?
Yep, it is found one possible bug today.
The text was updated successfully, but these errors were encountered: