1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Allow destructuring of callable array

Fixes #2653
This commit is contained in:
Matthew Brown 2020-01-17 10:02:58 -05:00
parent 471d7610f0
commit 2c48d42904
2 changed files with 19 additions and 1 deletions

View File

@ -625,7 +625,7 @@ class Union
*/
public function hasArray()
{
return isset($this->types['array']);
return isset($this->types['array']) || isset($this->types['callable-array']);
}
/**

View File

@ -713,6 +713,24 @@ class CallableTest extends TestCase
}
}'
],
'destructureCallableArray' => [
'<?php
function getCallable(): callable {
return [DateTimeImmutable::class, "createFromFormat"];
}
$callable = getCallable();
if (!is_array($callable)) {
exit;
}
[$classOrObject, $method] = $callable;',
[
'$classOrObject' => 'class-string|object',
'$method' => 'string'
]
],
];
}