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:
parent
3681762a9b
commit
f227af83c0
@ -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';
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user