Skip to content
Permalink
Browse files

Allow mixed callable params to be valid

  • Loading branch information...
muglug committed Apr 24, 2019
1 parent 3681762 commit f227af83c0fd802ad363c4cc6604aad5d3f1d0a2
Showing with 13 additions and 5 deletions.
  1. +4 −5 src/Psalm/Internal/Analyzer/TypeAnalyzer.php
  2. +9 −0 tests/CallableTest.php
@@ -1372,11 +1372,10 @@ public static function getCallableMethodIdFromObjectLike(ObjectLike $input_type_
$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 @@ function foo(callable $c): void {}
$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 {

0 comments on commit f227af8

Please sign in to comment.
You can’t perform that action at this time.