Skip to content

Commit

Permalink
Handle first class callable on unknown functions
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah committed Jan 31, 2022
1 parent 4729eb0 commit a598efb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,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 @@ -495,11 +497,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
4 changes: 4 additions & 0 deletions tests/ClosureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,10 @@ public static function __callStatic(string $name, array $args): mixed {
'error_levels' => [],
'8.1'
],
'unknownFirstClassCallable' => [
'<?php
unknown(...);',
],
];
}

Expand Down

0 comments on commit a598efb

Please sign in to comment.