From 30a39a0ee6e1b763bf6cee0a17995acd2e009a85 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Sun, 1 Jan 2017 19:24:15 -0500 Subject: [PATCH] Do not emit issue when callable is called --- .../Checker/Statements/Expression/CallChecker.php | 5 ++++- tests/ClosureTest.php | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Checker/Statements/Expression/CallChecker.php b/src/Psalm/Checker/Statements/Expression/CallChecker.php index 91a45622c..607ba3be2 100644 --- a/src/Psalm/Checker/Statements/Expression/CallChecker.php +++ b/src/Psalm/Checker/Statements/Expression/CallChecker.php @@ -122,7 +122,10 @@ class CallChecker $stmt->inferredType = $var_type_part->return_type; } } - } elseif (!$var_type_part->isMixed() && $var_type_part->value !== 'Closure') { + } elseif (!$var_type_part->isMixed() && + $var_type_part->value !== 'Closure' && + !$var_type_part->isCallable() + ) { $var_id = ExpressionChecker::getVarId( $stmt->name, $statements_checker->getFQCLN(), diff --git a/tests/ClosureTest.php b/tests/ClosureTest.php index a23ddbac7..c0cd79a07 100644 --- a/tests/ClosureTest.php +++ b/tests/ClosureTest.php @@ -139,6 +139,19 @@ class ClosureTest extends PHPUnit_Framework_TestCase $this->assertEquals('int', (string) $context->vars_in_scope['$a']); } + public function testCallable() + { + $stmts = self::$parser->parse('check(true, true, $context); + } + /** * @expectedException \Psalm\Exception\CodeException * @expectedExceptionMessage InvalidFunctionCall