1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Allow arrays to be called (ugh)

This commit is contained in:
Matthew Brown 2018-03-02 00:49:53 -05:00
parent 54cbee1265
commit ee6a9b98fb
2 changed files with 17 additions and 1 deletions

View File

@ -165,7 +165,11 @@ class FunctionCallChecker extends \Psalm\Checker\Statements\Expression\CallCheck
) {
// this is fine
$has_valid_function_call_type = true;
} elseif ($var_type_part instanceof TString) {
} elseif ($var_type_part instanceof TString
|| $var_type_part instanceof TArray
|| ($var_type_part instanceof Type\Atomic\ObjectLike
&& count($var_type_part->properties) === 2)
) {
// this is also kind of fine
$has_valid_function_call_type = true;
} elseif ($var_type_part instanceof TNull) {

View File

@ -538,6 +538,18 @@ class FunctionCallTest extends TestCase
'assertions' => [],
'error_levels' => ['UndefinedMethod'],
],
'validCallables' => [
'<?php
class A {
public static function b() : void {}
}
function c() : void {}
["a", "b"]();
"A::b"();
"c"();'
],
];
}