Skip to content

Conversation

@rajyan
Copy link
Contributor

@rajyan rajyan commented Mar 22, 2022

@rajyan
Copy link
Contributor Author

rajyan commented Mar 22, 2022

Didin't touch Coalesce in this PR, because going to fix in separate PR #1104

@rajyan rajyan changed the title Fix/issue 6870 expr early termination 2 Fix/issue 6870 expr early termination for BinaryOp Mar 22, 2022
@rajyan rajyan force-pushed the fix/issue-6870-expr-early-termination-2 branch from 23d6e09 to b5b8ce6 Compare March 23, 2022 00:13
@rajyan rajyan force-pushed the fix/issue-6870-expr-early-termination-2 branch from b5b8ce6 to 2b3b76d Compare March 23, 2022 00:14
@rajyan
Copy link
Contributor Author

rajyan commented Mar 23, 2022

Tests are not skipped in old PHP versions 🤔

solved

@ondrejmirtes
Copy link
Member

Sorry, I can't wrap my head around the fact there are two PRs for the same issue: #1104 + #1105 Can you please explain what's your intention here before I review?

@rajyan
Copy link
Contributor Author

rajyan commented Mar 23, 2022

@ondrejmirtes

#1104 is only for Coalesce now, and for solving other issues. I cherry picked the first two commits to this PR (which fixes phpstan/phpstan#6870, the scope for BinaryOp except Coalesce).

As https://phpstan.org/r/9ad910e5-7783-4441-9cb6-98548cce54eb shows, Coalesce is already working with this case because of #1063, but the scope is not precise enough like phpstan/phpstan#4885 is not solved.

I thought that Coalesce expr

$leftExpr ?? $rightExpr

process can be replaced by simulating isset Ternary

isset($leftExpr) ? $leftExpr : $rightExpr

which handles the scope problem perfectly (fixes phpstan/phpstan#4885), and also fixes a lot of issues like phpstan/phpstan#6026, issues caused from difference between the implementation of Coalesce and Isset_.
There are still several problems to fix with #1104, but the fact that phpstan/phpstan#6870 can be solved without fixing Coalesce, I separated into two PRs.

@ondrejmirtes ondrejmirtes merged commit abaca6d into phpstan:1.5.x Mar 24, 2022
@ondrejmirtes
Copy link
Member

Alright, thank you!

@rajyan rajyan deleted the fix/issue-6870-expr-early-termination-2 branch March 24, 2022 08:12
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.

Support "or throw" PHP 8 syntax to eliminate false return values Early termination not working for binary operators

2 participants