Skip to content

Commit 483652a

Browse files
phpstan-botclaude
andcommitted
Extract shouldUpdateAutoIndex() private method for readability
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4b48990 commit 483652a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Type/Constant/ConstantArrayTypeBuilder.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,7 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $opt
210210
$this->isList = TrinaryLogic::createNo();
211211
}
212212

213-
if (
214-
$offsetValue >= $max
215-
|| ($offsetValue < 0 && $max === 0 && PhpVersionStaticAccessor::getInstance()->updatesAutoIncrementKeyForNegativeValues())
216-
) {
213+
if ($this->shouldUpdateAutoIndex($offsetValue, $max)) {
217214
/** @var int|float $newAutoIndex */
218215
$newAutoIndex = $offsetValue + 1;
219216
if (is_float($newAutoIndex)) {
@@ -423,4 +420,13 @@ public function isList(): bool
423420
return $this->isList->yes();
424421
}
425422

423+
private function shouldUpdateAutoIndex(int $offsetValue, int $max): bool
424+
{
425+
if ($offsetValue >= $max) {
426+
return true;
427+
}
428+
429+
return $offsetValue < 0 && $max === 0 && PhpVersionStaticAccessor::getInstance()->updatesAutoIncrementKeyForNegativeValues();
430+
}
431+
426432
}

0 commit comments

Comments
 (0)