mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Fix callable without args not handled correctly
This commit is contained in:
parent
b38530ed0d
commit
f8a53ebc5d
@ -288,7 +288,8 @@ final class HighOrderFunctionArgHandler
|
||||
}
|
||||
|
||||
foreach ($container_param->type->getAtomicTypes() as $a) {
|
||||
if (($a instanceof TClosure || $a instanceof TCallable) && !$a->params) {
|
||||
// must check null explicitly, since no params (empty array) would not be handled correctly otherwise
|
||||
if (($a instanceof TClosure || $a instanceof TCallable) && $a->params === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2352,6 +2352,18 @@ class FunctionCallTest extends TestCase
|
||||
fooFoo("string");',
|
||||
'error_message' => 'InvalidScalarArgument',
|
||||
],
|
||||
'invalidArgumentCallableWithoutArgsUnion' => [
|
||||
'code' => '<?php
|
||||
function foo(int $a): void {}
|
||||
|
||||
/**
|
||||
* @param callable()|float $callable
|
||||
* @return void
|
||||
*/
|
||||
function acme($callable) {}
|
||||
acme("foo");',
|
||||
'error_message' => 'InvalidArgument',
|
||||
],
|
||||
'invalidArgumentWithDeclareStrictTypes' => [
|
||||
'code' => '<?php declare(strict_types=1);
|
||||
function fooFoo(int $a): void {}
|
||||
|
Loading…
Reference in New Issue
Block a user