Improve dead code detection after nested function calls with conditional never return type
Partial solution for phpstan/phpstan#7188: check expressions for terminating calls a bit more aggressively.
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 https://github.com/phpstan/phpstan/issues/4426 :)
That seems like a good idea - I'll look into it.
I've reduced it to a much simpler version that does the trick as well.
Of course, this makes sense :) Thank you.