-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Description
Bug report
Given the following code:
<?php declare(strict_types = 1);
class HelloWorld
{
public function sayHello(): void
{
$data = [
[
'elements' => [1, 2, 3],
'greet' => fn (int $value) => 'I am '.$value,
],
[
'elements' => ['hello', 'world'],
'greet' => fn (string $value) => 'I am '.$value,
],
];
foreach ($data as $entry) {
foreach ($entry['elements'] as $element) {
$entry['greet']($element);
}
}
}
}Shouldn't PHPStan detect that the data types of the array elements match the function parameter?
Code snippet that reproduces the problem
https://phpstan.org/r/dfcecd96-e249-4263-8dba-772224daf7fc
Expected output
The issue was reported incorrectly.
Did PHPStan help you today? Did it make you happy in any way?
No response
Reactions are currently unavailable