From 483b4c75f35eb76850284acc260ea83cb9e45fb1 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Sat, 7 Oct 2017 10:33:19 -0400 Subject: [PATCH] Fix #223 - array_map with too few args should have issue --- .../Statements/Expression/CallChecker.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Psalm/Checker/Statements/Expression/CallChecker.php b/src/Psalm/Checker/Statements/Expression/CallChecker.php index e9503f179..52277f7a2 100644 --- a/src/Psalm/Checker/Statements/Expression/CallChecker.php +++ b/src/Psalm/Checker/Statements/Expression/CallChecker.php @@ -1820,6 +1820,28 @@ class CallChecker } if ($method_id === 'array_map' || $method_id === 'array_filter') { + if ($method_id === 'array_map' && count($args) < 2) { + if (IssueBuffer::accepts( + new TooFewArguments( + 'Too few arguments for ' . $method_id, + $code_location + ), + $statements_checker->getSuppressedIssues() + )) { + return false; + } + } elseif ($method_id === 'array_filter' && count($args) < 1) { + if (IssueBuffer::accepts( + new TooFewArguments( + 'Too few arguments for ' . $method_id, + $code_location + ), + $statements_checker->getSuppressedIssues() + )) { + return false; + } + } + if (self::checkArrayFunctionArgumentsMatch( $statements_checker, $args,