-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
phpstan/phpstan-src
#4172Labels
Milestone
Description
Bug report
checkExplicitMixed: true is required to reproduce this bug.
Code snippet that reproduces the problem
<?php
namespace test;
/**
* @param mixed[] $a
*/
function acceptsArray(array $a) : void{
}
/**
* @param mixed[] $a
*/
function dummy(array $a) : void{
if(!is_array($a["test"])){
throw new \RuntimeException("oops");
}
acceptsArray($a['test']);
}
Notice that the isset() uses a double-quoted key, while the acceptsArray() uses a single-quoted key.
phpstan.org doesn't have a checkExplicitMixed option, so it doesn't reproduce there: https://phpstan.org/r/7f09bc66-f22a-407b-a78d-d81dc1002d71
Expected output
No error should be produced.
Actual output
------ ---------------------------------------------------------------------------
Line Test.php
------ ---------------------------------------------------------------------------
20 Parameter #1 $a of function test\acceptsArray expects array, mixed given.
------ ---------------------------------------------------------------------------
[ERROR] Found 1 error
Reactions are currently unavailable