Skip to content

Commit 76cb689

Browse files
committed
fix prop fetch
1 parent 6eaed6e commit 76cb689

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Analyser/ExprHandler/Helper/NonNullabilityHelper.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ public function ensureShallowNonNullability(MutatingScope $scope, Scope $origina
3030
}
3131

3232
// keep certainty
33-
$certainty = $originalScope->hasExpressionType($exprToSpecify);
33+
$certainty = TrinaryLogic::createYes();
34+
$hasExpressionType = $originalScope->hasExpressionType($exprToSpecify);
35+
if (!$hasExpressionType->no() || $exprToSpecify instanceof ArrayDimFetch) {
36+
$certainty = $hasExpressionType;
37+
}
38+
3439
$exprTypeWithoutNull = TypeCombinator::removeNull($exprType);
3540
if ($exprType->equals($exprTypeWithoutNull)) {
3641
$originalExprType = $originalScope->getType($exprToSpecify);

tests/PHPStan/Rules/Comparison/BooleanOrConstantConditionRuleTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,12 @@ public function testBug10305(): void
375375
{
376376
$this->treatPhpDocTypesAsCertain = true;
377377

378-
$this->analyse([__DIR__ . '/data/bug-10305.php'], []);
378+
$this->analyse([__DIR__ . '/data/bug-10305.php'], [
379+
[
380+
"Result of || is always true.",
381+
10
382+
]
383+
]);
379384
}
380385

381386
}

0 commit comments

Comments
 (0)