mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 23:08:46 +02:00
fix few Evaluators code
This commit is contained in:
@@ -5,9 +5,17 @@ namespace Combodo\iTop\PhpParser\Evaluation;
|
||||
use ModuleFileReaderException;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
use ReflectionFunction;
|
||||
|
||||
class FuncCallEvaluator extends AbstractExprEvaluator {
|
||||
public const WHITELIST=[
|
||||
"function_exists",
|
||||
"class_exists",
|
||||
"method_exists"
|
||||
];
|
||||
|
||||
public function GetHandledExpressionType(): ?string {
|
||||
return FuncCall::class;
|
||||
}
|
||||
@@ -15,9 +23,12 @@ class FuncCallEvaluator extends AbstractExprEvaluator {
|
||||
public function Evaluate(Expr $oExpr): mixed {
|
||||
/** @var FuncCall $oExpr */
|
||||
|
||||
$sFunction = $oExpr->name->name;
|
||||
$aWhiteList = ["function_exists", "class_exists", "method_exists"];
|
||||
if (! in_array($sFunction, $aWhiteList)){
|
||||
if ($oExpr->name instanceof Name){
|
||||
$sFunction = $oExpr->name->name;
|
||||
} else {
|
||||
$sFunction = PhpExpressionEvaluator::GetInstance()->EvaluateExpression($oExpr->name);
|
||||
}
|
||||
if (! in_array($sFunction, self::WHITELIST)){
|
||||
throw new ModuleFileReaderException("FuncCall $sFunction not supported");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user