Skip to content

Commit

Permalink
Merge pull request #10753 from edsrzf/arguments-isset-disable
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Feb 27, 2024
2 parents 60badd0 + 22f32c1 commit 9aa450b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ public static function analyze(
$was_inside_call = $context->inside_call;
$context->inside_call = true;

$was_inside_isset = $context->inside_isset;
$context->inside_isset = false;

if (ExpressionAnalyzer::analyze(
$statements_analyzer,
$arg->value,
Expand All @@ -240,11 +243,13 @@ public static function analyze(
false,
$high_order_template_result,
) === false) {
$context->inside_isset = $was_inside_isset;
$context->inside_call = $was_inside_call;

return false;
}

$context->inside_isset = $was_inside_isset;
$context->inside_call = $was_inside_call;

if ($high_order_callable_info && $high_order_template_result) {
Expand Down
10 changes: 10 additions & 0 deletions tests/FunctionCallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2506,6 +2506,16 @@ public function foo() : void {
}',
'error_message' => 'InvalidArgument',
],
'clearIssetContext' => [
'code' => '<?php
function greet(bool $arg): ?string
{
return $arg ? "hi" : null;
}
echo greet($undef) ?? "bye";',
'error_message' => 'UndefinedGlobalVariable',
],
'mixedArgument' => [
'code' => '<?php
function fooFoo(int $a): void {}
Expand Down

0 comments on commit 9aa450b

Please sign in to comment.