Skip to content

Commit

Permalink
Merge pull request #7321 from weirdan/dont-crash-on-array_map-first-c…
Browse files Browse the repository at this point in the history
…lass-callable
  • Loading branch information
weirdan committed Jan 6, 2022
2 parents 18ab5a0 + fe036d4 commit 46bcb62
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/Psalm/Internal/PhpVisitor/Reflector/ExpressionScanner.php
Expand Up @@ -125,6 +125,10 @@ private static function registerClassMapFunctionCall(
}
}

if ($node->isFirstClassCallable()) {
return;
}

if ($function_id === 'define') {
$first_arg_value = isset($node->getArgs()[0]) ? $node->getArgs()[0]->value : null;
$second_arg_value = isset($node->getArgs()[1]) ? $node->getArgs()[1]->value : null;
Expand Down
9 changes: 7 additions & 2 deletions tests/ClosureTest.php
Expand Up @@ -729,6 +729,12 @@ public static function __callStatic(string $name, array $args): mixed {
[],
'8.1'
],
'FirstClassCallable:array_map' => [
'<?php call_user_func(array_map(...), intval(...), ["1"]);',
'assertions' => [],
[],
'8.1',
],
];
}

Expand Down Expand Up @@ -1171,9 +1177,8 @@ public static function __callStatic(string $name, array $args): mixed {
'error_message' => 'MixedAssignment',
[],
false,
'8.1'
'8.1',
],

];
}
}

0 comments on commit 46bcb62

Please sign in to comment.