Files
iTop/setup/modulediscovery/evaluation/expression/StaticPropertyFetchEvaluator.php
2025-09-02 12:23:46 +02:00

31 lines
778 B
PHP

<?php
namespace evaluation\expression;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\StaticPropertyFetch;
class StaticPropertyFetchEvaluator implements iExprEvaluator {
public function GetHandledExpressionType(): string {
return StaticPropertyFetch::class;
}
public function Evaluate(Expr $oExpr): mixed {
/** @var StaticPropertyFetch $oExpr */
$sClassName = $oExpr->class->name;
$sProperty = $oExpr->name->name;
if (class_exists($sClassName)){
$class = new \ReflectionClass($sClassName);
if (array_key_exists($sProperty, $class->getStaticProperties())) {
$oReflectionProperty = $class->getProperty($sProperty);
if ($oReflectionProperty->isPublic()){
return $class->getStaticPropertyValue($sProperty);
}
}
}
return null;
}
}