diff --git a/src/Psalm/Checker/Statements/Expression/CallChecker.php b/src/Psalm/Checker/Statements/Expression/CallChecker.php index 3bfea2eb2..67495fa6f 100644 --- a/src/Psalm/Checker/Statements/Expression/CallChecker.php +++ b/src/Psalm/Checker/Statements/Expression/CallChecker.php @@ -121,18 +121,17 @@ class CallChecker } $method_id = null; + $function_params = null; + $in_call_map = false; + + $is_stubbed = false; + + $function_storage = null; + + $code_location = new CodeLocation($statements_checker->getSource(), $stmt); + $defined_constants = []; if ($context->check_functions) { - $in_call_map = false; - - $is_stubbed = false; - - $function_storage = null; - $function_params = null; - - $code_location = new CodeLocation($statements_checker->getSource(), $stmt); - - $defined_constants = []; if ($stmt->name instanceof PhpParser\Node\Expr) { if (ExpressionChecker::analyze($statements_checker, $stmt->name, $context) === false) { @@ -239,16 +238,18 @@ class CallChecker ); } } + } - if (self::checkFunctionArguments( - $statements_checker, - $stmt->args, - $function_params, - $context - ) === false) { - // fall through - } + if (self::checkFunctionArguments( + $statements_checker, + $stmt->args, + $function_params, + $context + ) === false) { + // fall through + } + if ($context->check_functions) { $generic_params = null; if ($stmt->name instanceof PhpParser\Node\Name && $method_id) { diff --git a/tests/FunctionCallTest.php b/tests/FunctionCallTest.php index 052a65d92..e4029c776 100644 --- a/tests/FunctionCallTest.php +++ b/tests/FunctionCallTest.php @@ -456,4 +456,29 @@ class FunctionCallTest extends PHPUnit_Framework_TestCase $file_checker->visitAndAnalyzeMethods($context); $this->assertEquals('array', (string) $context->vars_in_scope['$d']); } + + /** + * @return void + */ + public function testByRefAfterCallable() + { + Config::getInstance()->setCustomErrorLevel('MixedAssignment', Config::REPORT_SUPPRESS); + Config::getInstance()->setCustomErrorLevel('MixedArrayAccess', Config::REPORT_SUPPRESS); + + $stmts = self::$parser->parse('project_checker, $stmts); + $context = new Context(); + $file_checker->visitAndAnalyzeMethods($context); + } }