Skip to content

Commit 4e81da5

Browse files
authored
Merge branch refs/heads/1.10.x into 1.11.x
2 parents 8409cab + 6d11aa9 commit 4e81da5

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/Analyser/MutatingScope.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -1401,9 +1401,10 @@ private function resolveType(string $exprString, Expr $node): Type
14011401
return $this->initializerExprTypeResolver->getType($node, InitializerExprContext::fromScope($this));
14021402
} elseif ($node instanceof Object_) {
14031403
$castToObject = static function (Type $type): Type {
1404-
if (count($type->getConstantArrays()) > 0) {
1404+
$constantArrays = $type->getConstantArrays();
1405+
if (count($constantArrays) > 0) {
14051406
$objects = [];
1406-
foreach ($type->getConstantArrays() as $constantArray) {
1407+
foreach ($constantArrays as $constantArray) {
14071408
$properties = [];
14081409
$optionalProperties = [];
14091410
foreach ($constantArray->getKeyTypes() as $i => $keyType) {

src/Analyser/NodeScopeResolver.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -2134,11 +2134,12 @@ static function (): void {
21342134
) {
21352135
$extractedArg = $expr->getArgs()[0]->value;
21362136
$extractedType = $scope->getType($extractedArg);
2137-
if (count($extractedType->getConstantArrays()) > 0) {
2137+
$constantArrays = $extractedType->getConstantArrays();
2138+
if (count($constantArrays) > 0) {
21382139
$properties = [];
21392140
$optionalProperties = [];
21402141
$refCount = [];
2141-
foreach ($extractedType->getConstantArrays() as $constantArray) {
2142+
foreach ($constantArrays as $constantArray) {
21422143
foreach ($constantArray->getKeyTypes() as $i => $keyType) {
21432144
if ($keyType->isString()->no()) {
21442145
// integers as variable names not allowed
@@ -2160,7 +2161,7 @@ static function (): void {
21602161
}
21612162
}
21622163
foreach ($properties as $name => $type) {
2163-
$optional = in_array($name, $optionalProperties, true) || $refCount[$name] < count($extractedType->getConstantArrays());
2164+
$optional = in_array($name, $optionalProperties, true) || $refCount[$name] < count($constantArrays);
21642165
$scope = $scope->assignVariable($name, $type, $type, $optional ? TrinaryLogic::createMaybe() : TrinaryLogic::createYes());
21652166
}
21662167
} else {
@@ -2995,8 +2996,9 @@ private function getArrayFunctionAppendingType(FunctionReflection $functionRefle
29952996
foreach ($callArgs as $callArg) {
29962997
$callArgType = $scope->getType($callArg->value);
29972998
if ($callArg->unpack) {
2998-
if (count($callArgType->getConstantArrays()) === 1) {
2999-
$iterableValueTypes = $callArgType->getConstantArrays()[0]->getValueTypes();
2999+
$constantArrays = $callArgType->getConstantArrays();
3000+
if (count($constantArrays) === 1) {
3001+
$iterableValueTypes = $constantArrays[0]->getValueTypes();
30003002
} else {
30013003
$iterableValueTypes = [$callArgType->getIterableValueType()];
30023004
$nonConstantArrayWasUnpacked = true;

src/Reflection/InitializerExprTypeResolver.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,9 @@ public function getArrayType(Expr\Array_ $expr, callable $getTypeCallback): Type
501501

502502
$valueType = $getTypeCallback($arrayItem->value);
503503
if ($arrayItem->unpack) {
504-
if (count($valueType->getConstantArrays()) === 1) {
505-
$constantArrayType = $valueType->getConstantArrays()[0];
504+
$constantArrays = $valueType->getConstantArrays();
505+
if (count($constantArrays) === 1) {
506+
$constantArrayType = $constantArrays[0];
506507
$hasStringKey = false;
507508
foreach ($constantArrayType->getKeyTypes() as $keyType) {
508509
if ($keyType->isString()->yes()) {

0 commit comments

Comments
 (0)