Skip to content

Commit

Permalink
Fix undefined numeric offset
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Oct 1, 2019
1 parent f8a2eae commit 2ffdf1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,10 @@ protected static function checkFunctionArguments(
: null;

// if this modifies the array type based on further args
if ($method_id && in_array($method_id, ['array_push', 'array_unshift'], true) && $function_params) {
if ($method_id && in_array($method_id, ['array_push', 'array_unshift'], true)
&& $function_params
&& $args
) {
if (self::handleArrayAddition($statements_analyzer, $args, $context) === false) {
return false;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/FunctionCallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2460,6 +2460,11 @@ function test() : void {
}',
'error_message' => 'TypeDoesNotContainType',
],
'noCrashOnEmptyArrayPush' => [
'<?php
array_push();',
'error_message' => 'TooFewArguments',
],
];
}
}

0 comments on commit 2ffdf1b

Please sign in to comment.