Skip to content

Commit 8e30d38

Browse files
phpstan-botclaude
andcommitted
Rename isLiteralArray to isArrayExpression for clarity
The flag marks builders processing Expr\Array_ nodes (PHP array expression syntax), which have different auto-index semantics for negative keys in PHP 8.0-8.2 vs imperative assignment. The term "array expression" better matches the PHP parser terminology. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9ac8db3 commit 8e30d38

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/Php/PhpVersion.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ public function updatesAutoIncrementKeyForNegativeValues(): bool
516516
return $this->versionId >= 80300;
517517
}
518518

519-
public function updatesAutoIncrementKeyForNegativeValuesInArrayLiteral(): bool
519+
public function updatesAutoIncrementKeyForNegativeValuesInArrayExpression(): bool
520520
{
521521
return $this->versionId >= 80000;
522522
}

src/Reflection/InitializerExprTypeResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ public function getArrayType(Expr\Array_ $expr, callable $getTypeCallback): Type
639639
}
640640

641641
$arrayBuilder = ConstantArrayTypeBuilder::createEmpty();
642-
$arrayBuilder->setLiteralArray();
642+
$arrayBuilder->setArrayExpression();
643643
$isList = null;
644644
$hasOffsetValueTypes = [];
645645
foreach ($expr->items as $arrayItem) {

src/Type/Constant/ConstantArrayTypeBuilder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ final class ConstantArrayTypeBuilder
4242

4343
private bool $oversized = false;
4444

45-
private bool $isLiteralArray = false;
45+
private bool $isArrayExpression = false;
4646

4747
/**
4848
* @param list<Type> $keyTypes
@@ -65,9 +65,9 @@ public static function createEmpty(): self
6565
return new self([], [], [0], [], TrinaryLogic::createYes());
6666
}
6767

68-
public function setLiteralArray(): void
68+
public function setArrayExpression(): void
6969
{
70-
$this->isLiteralArray = true;
70+
$this->isArrayExpression = true;
7171
}
7272

7373
public static function createFromConstantArray(ConstantArrayType $startArrayType): self
@@ -443,7 +443,7 @@ private function shouldUpdateAutoIndex(int $offsetValue, int $max): bool
443443
return true;
444444
}
445445

446-
return $this->isLiteralArray && $phpVersion->updatesAutoIncrementKeyForNegativeValuesInArrayLiteral();
446+
return $this->isArrayExpression && $phpVersion->updatesAutoIncrementKeyForNegativeValuesInArrayExpression();
447447
}
448448

449449
}

0 commit comments

Comments
 (0)