diff --git a/src/Type/ArrayType.php b/src/Type/ArrayType.php index 76e5392f50..b8487cde25 100644 --- a/src/Type/ArrayType.php +++ b/src/Type/ArrayType.php @@ -176,6 +176,9 @@ public function getIterableKeyType(): Type if ($keyType instanceof MixedType && !$keyType instanceof TemplateMixedType) { return new BenevolentUnionType([new IntegerType(), new StringType()]); } + if ($keyType instanceof StrictMixedType) { + return new BenevolentUnionType([new IntegerType(), new StringType()]); + } return $keyType; } diff --git a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php index 6d0dd8a99d..2103a67369 100644 --- a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php @@ -876,4 +876,15 @@ public function testBug5661(): void $this->analyse([__DIR__ . '/data/bug-5661.php'], []); } + public function testBug5872(): void + { + $this->checkExplicitMixed = true; + $this->analyse([__DIR__ . '/data/bug-5872.php'], [ + [ + 'Parameter #2 $array of function array_map expects array, mixed given.', + 12, + ], + ]); + } + } diff --git a/tests/PHPStan/Rules/Functions/data/bug-5872.php b/tests/PHPStan/Rules/Functions/data/bug-5872.php new file mode 100644 index 0000000000..ff16caea99 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/bug-5872.php @@ -0,0 +1,15 @@ +