move PhpParser/Evaluation classes in a specific namespave + composer dumpautoload

This commit is contained in:
odain
2025-09-02 19:19:56 +02:00
parent 1962cd7a88
commit ac2b787e09
33 changed files with 92 additions and 42 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace Combodo\iTop\PhpParser\Evaluation;;
use ModuleFileReaderException;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\FuncCall;
use ReflectionFunction;
class FuncCallEvaluator implements iExprEvaluator {
public function GetHandledExpressionType(): string {
return FuncCall::class;
}
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)){
throw new ModuleFileReaderException("FuncCall $sFunction not supported");
}
$aArgs=[];
foreach ($oExpr->args as $arg){
/** @var \PhpParser\Node\Arg $arg */
$aArgs[]=$arg->value->value;
}
$oReflectionFunction = new ReflectionFunction($sFunction);
return $oReflectionFunction->invoke(...$aArgs);
}
}