mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-28 21:18:46 +02:00
31 lines
778 B
PHP
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;
|
|
}
|
|
} |