Skip to content

Commit

Permalink
Prevent crashes on array_map(...)
Browse files Browse the repository at this point in the history
Fixes #7305
  • Loading branch information
weirdan committed Jan 6, 2022
1 parent 513b263 commit fe036d4
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 fe036d4

Please sign in to comment.