diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php index fe53f5027..5107fd654 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php @@ -297,7 +297,12 @@ class FunctionLikeNodeScanner null ); - $negated_formula = \Psalm\Internal\Algebra::negateFormula($if_clauses); + try { + $negated_formula = \Psalm\Internal\Algebra::negateFormula($if_clauses); + } catch (\Psalm\Exception\ComplicatedExpressionException $e) { + $var_assertions = []; + break; + } $rules = \Psalm\Internal\Algebra::getTruthsFromFormula($negated_formula); diff --git a/tests/AssertAnnotationTest.php b/tests/AssertAnnotationTest.php index 9e5b92e7c..a5055c3ad 100644 --- a/tests/AssertAnnotationTest.php +++ b/tests/AssertAnnotationTest.php @@ -1414,6 +1414,24 @@ class AssertAnnotationTest extends TestCase } ?>' ], + 'implicitComplexAssertionNoCrash' => [ + 'status && "complete" === $status) + || ("canceled" === $this->status && "pending" === $status) + || ("complete" === $this->status && "canceled" === $status) + || ("complete" === $this->status && "pending" === $status) + ) { + throw new \LogicException(); + } + } + }' + ], ]; } diff --git a/tests/PropertyTypeTest.php b/tests/PropertyTypeTest.php index cdf5a1369..c443ef473 100644 --- a/tests/PropertyTypeTest.php +++ b/tests/PropertyTypeTest.php @@ -2385,6 +2385,16 @@ class PropertyTypeTest extends TestCase [], '8.0' ], + 'dynamicPropertyFetch' => [ + '{$b} ?? null; + }' + ], ]; }