1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Merge pull request #9519 from edsrzf/eval-inside-call

This commit is contained in:
Bruce Weirdan 2023-03-15 15:47:58 -04:00 committed by GitHub
commit 70a024f5e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View File

@ -26,7 +26,10 @@ class EvalAnalyzer
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();

View File

@ -709,6 +709,10 @@ class UnusedCodeTest extends TestCase
return $i;
}',
],
'usedFunctionCallInEval' => [
'code' => '<?php
eval(str_repeat("a", 10));',
],
'usedFunctionCallInsideSwitchWithTernary' => [
'code' => '<?php
function getArg(string $method) : void {

View File

@ -115,6 +115,13 @@ class UnusedVariableTest extends TestCase
unset($arr[$a]);',
],
'eval' => [
'code' => '<?php
if (rand()) {
$v = "";
eval($v);
}',
],
'usedVariables' => [
'code' => '<?php
/** @return string */