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: Access to an undefined property T of A|B|C::$name (regression) #6566

Closed
LastDragon-ru opened this issue Feb 5, 2022 · 5 comments

Comments

@LastDragon-ru
Copy link

LastDragon-ru commented Feb 5, 2022

Bug report

Error appeared after

  • Upgrading phpstan/phpstan (dev-master 90cdfea => dev-master 9747308)

v1.4.5 is fine

Code snippet that reproduces the problem

https://phpstan.org/r/cd4aa1fe-61dc-46c6-bfd5-931540ab74e4

Expected output

no error

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

Yep, it found one very stupid typo...

@ondrejmirtes
Copy link
Member

Thank you very much for trying out dev-master and finding this bug! Although I hope you're using a stable version in your usual day-to-day work :)

/cc @arnaud-lb I will try to improve tryRemove in TemplateUnionType, I have some ideas about that. Also I suspect we'll need to have Type::tryIntersect so I'll try to do it as well. I'll reach back if I'm gonna need some assistance with that :)

@arnaud-lb
Copy link
Contributor

@ondrejmirtes it may be safe to apply ::remove() on the bound and return a new template type with that bound, since ::remove() narrows the type. With phpstan/phpstan-src#999, the resulting template type will also still be accepted by the original template type.

@ondrejmirtes
Copy link
Member

Yeah, that's exactly what I want to do. I'm a bit surprised that intersection works already: https://phpstan.org/r/da79b871-df02-47e0-99f4-9561f2949499

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@0d28835

@github-actions
Copy link

github-actions bot commented Mar 9, 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 Mar 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants