1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Allow mixed callable params to be valid

This commit is contained in:
Brown 2019-04-24 12:54:35 -04:00
parent 3681762a9b
commit f227af83c0
2 changed files with 13 additions and 5 deletions

View File

@ -1372,11 +1372,10 @@ class TypeAnalyzer
$lhs = $input_type_part->properties[0];
$rhs = $input_type_part->properties[1];
if ($rhs->hasMixed()
|| $rhs->hasScalar()
|| !$rhs->isSingleStringLiteral()
) {
if (!$rhs->hasString()) {
$rhs_low_info = $rhs->hasMixed() || $rhs->hasScalar();
if ($rhs_low_info || !$rhs->isSingleStringLiteral()) {
if (!$rhs_low_info && !$rhs->hasString()) {
return 'not-callable';
}

View File

@ -146,6 +146,15 @@ class CallableTest extends TestCase
$a = new A();
foo([$a, "bar"]);',
],
'callableMethodArrayCallableMissingTypes' => [
'<?php
function foo(callable $c): void {}
/** @psalm-suppress MissingParamType */
function bar($a, $b) : void {
foo([$a, $b]);
}',
],
'arrayMapCallableMethod' => [
'<?php
class A {