Skip to content
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 Property HelloWorld::$bug (WeakMap<stdClass, stdClass>) does not accept WeakMap<object, mixed>|WeakMap<stdClass, stdClass>. #12250

Open
netpok opened this issue Dec 12, 2024 · 0 comments · May be fixed by phpstan/phpstan-src#3728
Labels
Milestone

Comments

@netpok
Copy link

netpok commented Dec 12, 2024

Bug report

Hello this issue is very similar to #5551. Phpstan reports an error when new WeakMap is assigned to a templated variable using the null coalesce assignment operator.

I tried to fix this and I could get it working by adding AssignOp\Coalesce to the NewAssignedToPropertyVisitor.php and it passes all tests however I'm not sure whether this is a good solution or not because the coalesce assignment is conditional while the current ones are not.

I made a draft PR about this: phpstan/phpstan-src#3728.

Code snippet that reproduces the problem

https://phpstan.org/r/0b3630b5-8631-4fd7-938f-31d4c04d0666

Expected output

no error

Did PHPStan help you today? Did it make you happy in any way?

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants