Skip to content

Commit

Permalink
Merge pull request #9519 from edsrzf/eval-inside-call
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Mar 15, 2023
2 parents a11fd94 + ce3f7fc commit 70a024f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ public static function analyze(
PhpParser\Node\Expr\Eval_ $stmt,
Context $context
): void {
$was_inside_call = $context->inside_call;
$context->inside_call = true;
ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context);
$context->inside_call = $was_inside_call;

$codebase = $statements_analyzer->getCodebase();

Expand Down
4 changes: 4 additions & 0 deletions tests/UnusedCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,10 @@ function takesMixed($i) : int {
return $i;
}',
],
'usedFunctionCallInEval' => [
'code' => '<?php
eval(str_repeat("a", 10));',
],
'usedFunctionCallInsideSwitchWithTernary' => [
'code' => '<?php
function getArg(string $method) : void {
Expand Down
7 changes: 7 additions & 0 deletions tests/UnusedVariableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ public function providerValidCodeParse(): array
unset($arr[$a]);',
],
'eval' => [
'code' => '<?php
if (rand()) {
$v = "";
eval($v);
}',
],
'usedVariables' => [
'code' => '<?php
/** @return string */
Expand Down

0 comments on commit 70a024f

Please sign in to comment.