Skip to content

Commit d00a194

Browse files
committed
TASK: Don't narrow nullableString === true as string
1 parent 560c97d commit d00a194

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/TypeSystem/Narrower/ExpressionTypeNarrower.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ public function narrowTypesOfSymbolsIn(ExpressionNode $expressionNode, TypeNarro
7878
return NarrowedTypes::empty();
7979
}
8080

81+
if ($other->root instanceof IdentifierNode) {
82+
return NarrowedTypes::empty();
83+
}
84+
8185
return $this->narrowTypesOfSymbolsIn(
8286
$other,
8387
$boolean->value ? $contextBasedOnOperator : $contextBasedOnOperator->negate()

test/Unit/TypeSystem/Narrower/ExpressionTypeNarrowerTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ public function narrowedExpressionsExamples(): mixed
7676
'nullableString === variableOfTypeNull' => [
7777
'nullableString === variableOfTypeNull', $variableIsNull
7878
],
79+
80+
'nullableString === true' => [
81+
'nullableString === true',
82+
NarrowedTypes::empty()
83+
],
7984
];
8085
}
8186

0 commit comments

Comments
 (0)