mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Be better about dealing with byref args when not checking functions
This commit is contained in:
parent
8ae4bf6a18
commit
32dd5d5512
@ -121,19 +121,18 @@ class CallChecker
|
||||
}
|
||||
|
||||
$method_id = null;
|
||||
|
||||
if ($context->check_functions) {
|
||||
$function_params = null;
|
||||
$in_call_map = false;
|
||||
|
||||
$is_stubbed = false;
|
||||
|
||||
$function_storage = null;
|
||||
$function_params = null;
|
||||
|
||||
$code_location = new CodeLocation($statements_checker->getSource(), $stmt);
|
||||
|
||||
$defined_constants = [];
|
||||
|
||||
if ($context->check_functions) {
|
||||
|
||||
if ($stmt->name instanceof PhpParser\Node\Expr) {
|
||||
if (ExpressionChecker::analyze($statements_checker, $stmt->name, $context) === false) {
|
||||
return false;
|
||||
@ -239,6 +238,7 @@ class CallChecker
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (self::checkFunctionArguments(
|
||||
$statements_checker,
|
||||
@ -249,6 +249,7 @@ class CallChecker
|
||||
// fall through
|
||||
}
|
||||
|
||||
if ($context->check_functions) {
|
||||
$generic_params = null;
|
||||
|
||||
if ($stmt->name instanceof PhpParser\Node\Name && $method_id) {
|
||||
|
@ -456,4 +456,29 @@ class FunctionCallTest extends PHPUnit_Framework_TestCase
|
||||
$file_checker->visitAndAnalyzeMethods($context);
|
||||
$this->assertEquals('array<string, int>', (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('<?php
|
||||
/**
|
||||
* @param callable $callback
|
||||
* @return void
|
||||
*/
|
||||
function route($callback) {
|
||||
if (!is_callable($callback)) { }
|
||||
$a = preg_match("", "", $b);
|
||||
if ($b[0]) {}
|
||||
}
|
||||
');
|
||||
|
||||
$file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts);
|
||||
$context = new Context();
|
||||
$file_checker->visitAndAnalyzeMethods($context);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user