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

Assigning generic objects without constructor to nullable properties reports false positives #4526

Closed
dktapps opened this issue Feb 11, 2021 · 3 comments · Fixed by phpstan/phpstan-src#1730

Comments

@dktapps
Copy link
Sponsor Contributor

dktapps commented Feb 11, 2021

Bug report

Code snippet that reproduces the problem

https://phpstan.org/r/708c1e20-8078-42f0-b18a-d22aaf41ea21

Expected output

No error should be reported.

@ondrejmirtes ondrejmirtes added this to the Generics milestone Feb 12, 2021
@phpstan-bot
Copy link

phpstan-bot commented Sep 17, 2021

@dktapps After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
+10: Property HelloWorld::$map is never read, only written.
 13: Property HelloWorld::$map (SplObjectStorage<DateTime, DateTimeImmutable>|null) does not accept SplObjectStorage<object, mixed>.
Full report
Line Error
10 Property HelloWorld::$map is never read, only written.
13 `Property HelloWorld::$map (SplObjectStorage<DateTime, DateTimeImmutable>

@phpstan-bot
Copy link

phpstan-bot commented Sep 17, 2021

@dktapps After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
+10: Property HelloWorld::$map is never read, only written.
 13: Property HelloWorld::$map (SplObjectStorage<DateTime, DateTimeImmutable>|null) does not accept SplObjectStorage<object, mixed>.
Full report
Line Error
10 Property HelloWorld::$map is never read, only written.
13 `Property HelloWorld::$map (SplObjectStorage<DateTime, DateTimeImmutable>

@github-actions
Copy link

github-actions bot commented Oct 22, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants