-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Milestone
Description
Summary of a problem or a feature request
Using a string argument in the function declaration that then is used in array_key_exists with an array where all the key's are string versions of integers will provide the error Call to function array_key_exists() with string and array(123 => 'test') will always evaluate to false.
With phpstan 0.10.5 and php 7.2.9.
Code snippet that reproduces the problem
<?php
namespace Project\Test;
class TestClass
{
public function test(string $index)
{
$array = [
"123" => "test"
];
return array_key_exists($index, $array);
}
}
but if you run
<?php
declare(strict_types = 1);
use Project\Test\TestClass;
require_once __DIR__ . '/vendor/autoload.php';
$test = new TestClass();
var_dump($test->test("123"));
it will log bool(true)
https://phpstan.org/r/e2d1c03a-235d-410a-8966-24bc4987167d
Expected output
There should not be any issue raised.
Reactions are currently unavailable