Skip to content

Improve dead code detection after nested function calls with conditional never return type#1378

Merged
ondrejmirtes merged 1 commit intophpstan:1.8.xfrom
rvanvelzen:conditional-never
Sep 2, 2022
Merged

Improve dead code detection after nested function calls with conditional never return type#1378
ondrejmirtes merged 1 commit intophpstan:1.8.xfrom
rvanvelzen:conditional-never

Conversation

@rvanvelzen
Copy link
Copy Markdown
Contributor

Partial solution for phpstan/phpstan#7188: check expressions for terminating calls a bit more aggressively.

@ondrejmirtes
Copy link
Copy Markdown
Member

I think that correct solution would be to handle this similarly to $hasYield and $throwPoints - to collect this information in ExpressionResult and StatementResult. In the end findEarlyTerminatingExpr wouldn't be needed at all.

Another similar data like this to gather is "purity" - "is this expression/statement pure or not?" It's unrelated to this PR, I'm just saying is another thing that should be done in the future, to solve phpstan/phpstan#4426 :)

@rvanvelzen rvanvelzen marked this pull request as draft June 1, 2022 06:51
@rvanvelzen
Copy link
Copy Markdown
Contributor Author

That seems like a good idea - I'll look into it.

@rvanvelzen rvanvelzen changed the base branch from 1.7.x to 1.8.x September 2, 2022 06:55
@rvanvelzen
Copy link
Copy Markdown
Contributor Author

I've reduced it to a much simpler version that does the trick as well.

@rvanvelzen rvanvelzen marked this pull request as ready for review September 2, 2022 06:57
@ondrejmirtes
Copy link
Copy Markdown
Member

Of course, this makes sense :) Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants