diff --git a/src/Type/Constant/ConstantArrayType.php b/src/Type/Constant/ConstantArrayType.php index 3853794348..3422c8ce0b 100644 --- a/src/Type/Constant/ConstantArrayType.php +++ b/src/Type/Constant/ConstantArrayType.php @@ -387,6 +387,25 @@ public function isSuperTypeOf(Type $type): TrinaryLogic $results[] = $isValueSuperType; } + if ( + $this->isList->yes() + && $type->isList->yes() + && count($this->keyTypes) !== count($type->keyTypes) + && count($type->optionalKeys) === 0 + ) { + $keepSeparate = true; + foreach ($this->valueTypes as $valueType) { + if ($valueType->isConstantValue()->yes()) { + $keepSeparate = false; + break; + } + } + + if ($keepSeparate) { + return TrinaryLogic::createNo(); + } + } + return TrinaryLogic::createYes()->and(...$results); } diff --git a/tests/PHPStan/Analyser/nsrt/bug11488.php b/tests/PHPStan/Analyser/nsrt/bug11488.php new file mode 100644 index 0000000000..b6acdaa452 --- /dev/null +++ b/tests/PHPStan/Analyser/nsrt/bug11488.php @@ -0,0 +1,64 @@ +