private compileConstFetch ( PhpParser\Node\Expr\ConstFetch $constNode ) : boolean | null | ||
$constNode | PhpParser\Node\Expr\ConstFetch | |
Результат | boolean | null |
private function compileConstFetch(Node\Expr\ConstFetch $constNode)
{
$firstName = reset($constNode->name->parts);
switch ($firstName) {
case 'null':
return null;
case 'false':
return false;
case 'true':
return true;
default:
if (!defined($firstName)) {
throw new Exception\UnableToCompileNode(sprintf('Constant "%s" has not been defined', $firstName));
}
return constant($firstName);
}
}