1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix #1200 - no fatal error in array_map when not checking functions

This commit is contained in:
Brown 2019-01-15 17:53:23 -05:00
parent f5a81249e0
commit 8d61cb4816
2 changed files with 19 additions and 4 deletions

View File

@ -1166,7 +1166,8 @@ class CallAnalyzer
if (self::checkArrayFunctionArgumentsMatch(
$statements_analyzer,
$args,
$method_id
$method_id,
$context->check_functions
) === false
) {
return false;
@ -1282,7 +1283,8 @@ class CallAnalyzer
protected static function checkArrayFunctionArgumentsMatch(
StatementsAnalyzer $statements_analyzer,
array $args,
$method_id
$method_id,
bool $check_functions
) {
$closure_index = $method_id === 'array_map' ? 0 : 1;
@ -1336,7 +1338,8 @@ class CallAnalyzer
$closure_arg,
$min_closure_param_count,
$max_closure_param_count,
$array_arg_types
$array_arg_types,
$check_functions
) === false) {
return false;
}
@ -1359,7 +1362,8 @@ class CallAnalyzer
PhpParser\Node\Arg $closure_arg,
$min_closure_param_count,
$max_closure_param_count,
array $array_arg_types
array $array_arg_types,
bool $check_functions
) {
$project_analyzer = $statements_analyzer->getFileAnalyzer()->project_analyzer;
@ -1426,6 +1430,10 @@ class CallAnalyzer
);
}
} else {
if (!$check_functions) {
continue;
}
$function_storage = $codebase->functions->getStorage(
$statements_analyzer,
$function_id

View File

@ -1334,6 +1334,13 @@ class FunctionCallTest extends TestCase
function sort() : void {}',
],
'arrayMapAfterFunctionMissingFile' => [
'<?php
require_once(FOO);
$urls = array_map("strval", [1, 2, 3]);',
[],
'error_levels' => ['UndefinedConstant', 'UnresolvableInclude'],
],
];
}