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

infer type via isset condition #10088

Closed
staabm opened this issue Nov 4, 2023 · 6 comments
Closed

infer type via isset condition #10088

staabm opened this issue Nov 4, 2023 · 6 comments

Comments

@staabm
Copy link
Contributor

staabm commented Nov 4, 2023

Feature request

no error in https://phpstan.org/r/d4d3024d-f355-4d05-968d-d7cc6a2e1dcf

found while investigating phpstan/phpstan-src#2666 (comment)

@ondrejmirtes
Copy link
Member

Alright, I looked into this in detail and this is what I found out. The fact that before it didn't report an error was a happy accident and actually a bug because revertNonNullability restored the expression with wrong certainty.

We need to make PHPStan understand what $link_mode = isset($shortcut_id) ? "remove" : "add"; does and create a conditional expression based on that. I'm try to gonna look into it.

@ondrejmirtes
Copy link
Member

I managed to fix this on top of your PR with this commit: phpstan/phpstan-src@c1310c4

@staabm
Copy link
Contributor Author

staabm commented Nov 4, 2023

Thanks!

@staabm
Copy link
Contributor Author

staabm commented Nov 5, 2023

Should be re-opened because of revert

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src#2710

Copy link

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 Dec 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants