Skip to content

Commit

Permalink
Merge pull request #7546 from orklah/impure-callable
Browse files Browse the repository at this point in the history
Handle first class callable on unknown functions
  • Loading branch information
orklah authored Jan 31, 2022
2 parents 041145d + 5a19d42 commit 68e67ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,8 @@ private static function handleNamedFunction(
$is_maybe_root_function = !$function_name instanceof PhpParser\Node\Name\FullyQualified
&& count($function_name->parts) === 1;

$args = $stmt->isFirstClassCallable() ? [] : $stmt->getArgs();

if (!$function_call_info->in_call_map) {
$predefined_functions = $codebase->config->getPredefinedFunctions();
$is_predefined = isset($predefined_functions[strtolower($original_function_id)])
Expand All @@ -496,11 +498,10 @@ private static function handleNamedFunction(
$function_call_info->function_id,
$code_location,
$is_maybe_root_function
) === false
) {
if (ArgumentsAnalyzer::analyze(
) === false) {
if ($args && ArgumentsAnalyzer::analyze(
$statements_analyzer,
$stmt->getArgs(),
$args,
null,
null,
true,
Expand Down
5 changes: 5 additions & 0 deletions tests/ClosureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,11 @@ public static function __callStatic(string $name, array $args): mixed {
'error_levels' => [],
'8.1'
],
'unknownFirstClassCallable' => [
'<?php
/** @psalm-suppress UndefinedFunction */
unknown(...);',
],
];
}

Expand Down

0 comments on commit 68e67ae

Please sign in to comment.