Skip to content

Commit 109b3c9

Browse files
committed
Revert "Fix false positive about offset that's ensured with array_key_exists"
This reverts commit edd54db.
1 parent edd54db commit 109b3c9

File tree

3 files changed

+2
-60
lines changed

3 files changed

+2
-60
lines changed

src/Analyser/MutatingScope.php

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4571,35 +4571,8 @@ public function addTypeToExpression(Expr $expr, Type $type): self
45714571
if ($originalExprType->equals($nativeType)) {
45724572
$newType = TypeCombinator::intersect($type, $originalExprType);
45734573
if ($newType->isConstantScalarValue()->yes() && $newType->equals($originalExprType)) {
4574-
$exprString = $this->getNodeKey($expr);
4575-
if (array_key_exists($exprString, $this->expressionTypes)) {
4576-
// don't add the same type over and over again to improve performance
4577-
return $this;
4578-
}
4579-
4580-
$expressionTypes = $this->expressionTypes;
4581-
$expressionTypes[$exprString] = new ExpressionTypeHolder($expr, $type, TrinaryLogic::createYes());
4582-
$nativeTypes = $this->nativeExpressionTypes;
4583-
$nativeTypes[$exprString] = new ExpressionTypeHolder($expr, $nativeType, TrinaryLogic::createYes());
4584-
4585-
return $this->scopeFactory->create(
4586-
$this->context,
4587-
$this->isDeclareStrictTypes(),
4588-
$this->getFunction(),
4589-
$this->getNamespace(),
4590-
$expressionTypes,
4591-
$nativeTypes,
4592-
$this->conditionalExpressions,
4593-
$this->inClosureBindScopeClasses,
4594-
$this->anonymousFunctionReflection,
4595-
$this->inFirstLevelStatement,
4596-
$this->currentlyAssignedExpressions,
4597-
$this->currentlyAllowedUndefinedExpressions,
4598-
$this->inFunctionCallsStack,
4599-
$this->afterExtractCall,
4600-
$this->parentScope,
4601-
$this->nativeTypesPromoted,
4602-
);
4574+
// don't add the same type over and over again to improve performance
4575+
return $this;
46034576
}
46044577
return $this->specifyExpressionType($expr, $newType, $newType, TrinaryLogic::createYes());
46054578
}

tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,9 +1000,4 @@ public function testBug10492(): void
10001000
]);
10011001
}
10021002

1003-
public function testBug13526(): void
1004-
{
1005-
$this->analyse([__DIR__ . '/data/bug-13526.php'], []);
1006-
}
1007-
10081003
}

tests/PHPStan/Rules/Arrays/data/bug-13526.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)