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

Fix/issue 7109 #1253

Merged
merged 4 commits into from Apr 27, 2022
Merged

Fix/issue 7109 #1253

merged 4 commits into from Apr 27, 2022

Conversation

rajyan
Copy link
Contributor

@rajyan rajyan commented Apr 27, 2022

fixes phpstan/phpstan#7109

See phpstan/phpstan#7109 (comment) for the discussion and implementation

@rajyan
Copy link
Contributor Author

rajyan commented Apr 27, 2022

@ondrejmirtes
I'm almost done except the error message. Do we need a node connecting visitor to change messages by coalesce/isset/empty?

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is really nice! I'll look into improving the error message myself 😊

@rajyan rajyan marked this pull request as ready for review April 27, 2022 06:21
@ondrejmirtes ondrejmirtes merged commit e0cf36d into phpstan:1.6.x Apr 27, 2022
@ondrejmirtes
Copy link
Member

Thank you. I'll try to improve the message directly on the branch.

@rajyan rajyan deleted the fix/issue-7109 branch April 27, 2022 08:24
@ondrejmirtes
Copy link
Member

Alright, done: 54f1544

I took advantage of IssetCheck already knowing the right context, I also tried to preserve the original behaviour as much as possible.

@rajyan
Copy link
Contributor Author

rajyan commented Apr 27, 2022

@ondrejmirtes
Thank you. Your changes looks better!
Didn't need to check https://github.com/phpstan/phpstan-src/pull/1253/files#diff-5cc10d718dd4dbca2d13640be20698dff3831518d541839da32e32ac86ab4c50L26-L34
because null safe property fetch is always unnecessary.

@rajyan
Copy link
Contributor Author

rajyan commented Apr 27, 2022

@ondrejmirtes

always unnecessary.

Oh, it was not.
phpstan/phpstan#7109 (comment)

null->test->call() ?? "test";

this might be an edge case of this fix.

When there is a method call, all expression before it is evalauted (and property fetch on null cause a warning)

@ondrejmirtes
Copy link
Member

@rajyan Can you please show that on phpstan.org/try and post the expected output? Thanks :)

@rajyan
Copy link
Contributor Author

rajyan commented Apr 27, 2022

@ondrejmirtes
Sorry, on second thought, your fix looks perfect!

@ondrejmirtes
Copy link
Member

Alright, feel free to submit a regression test for the null-> scenario :)

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