staticField() final public static method

final public static staticField ( Expression $class, Expression $name ) : StaticFieldExpression
$class Expression
$name Expression
return StaticFieldExpression
Beispiel #1
0
 public function expressions()
 {
     return [[O\Expression::arrayExpression([])], [O\Expression::arrayItem(null, O\Expression::value(0), false)], [O\Expression::assign(O\Expression::value(0), O\Operators\Assignment::EQUAL, O\Expression::value(0))], [O\Expression::binaryOperation(O\Expression::value(0), O\Operators\Binary::ADDITION, O\Expression::value(0))], [O\Expression::unaryOperation(O\Operators\Unary::PLUS, O\Expression::value(0))], [O\Expression::cast(O\Operators\Cast::STRING, O\Expression::value(0))], [O\Expression::closure(false, false, [], [], [])], [O\Expression::closureUsedVariable('var')], [O\Expression::emptyExpression(O\Expression::value(0))], [O\Expression::field(O\Expression::value(0), O\Expression::value(0))], [O\Expression::functionCall(O\Expression::value(0))], [O\Expression::index(O\Expression::value(0), O\Expression::value(0))], [O\Expression::invocation(O\Expression::value(0))], [O\Expression::issetExpression([O\Expression::value(0)])], [O\Expression::unsetExpression([O\Expression::value(0)])], [O\Expression::methodCall(O\Expression::value(0), O\Expression::value(0))], [O\Expression::newExpression(O\Expression::value(0))], [O\Expression::parameter('')], [O\Expression::argument(O\Expression::value(0))], [O\Expression::returnExpression()], [O\Expression::staticMethodCall(O\Expression::value(0), O\Expression::value(0))], [O\Expression::staticField(O\Expression::value(0), O\Expression::value(0))], [O\Expression::ternary(O\Expression::value(0), null, O\Expression::value(0))], [O\Expression::throwExpression(O\Expression::value(0))], [O\Expression::value(0)], [O\Expression::variable(O\Expression::value(0))], [O\Expression::constant('foo')], [O\Expression::classConstant(O\Expression::value(0), 'foo')]];
 }
Beispiel #2
0
 public function parseExpressionNode(Node\Expr $node)
 {
     switch (true) {
         case $mappedNode = $this->parseOperatorNode($node):
             return $mappedNode;
         case $node instanceof Node\Scalar && ($mappedNode = $this->parseScalarNode($node)):
             return $mappedNode;
         case $node instanceof Node\Expr\Variable:
             return Expression::variable($this->parseNameNode($node->name));
         case $node instanceof Node\Expr\Array_:
             return $this->parseArrayNode($node);
         case $node instanceof Node\Expr\FuncCall:
             return $this->parseFunctionCallNode($node);
         case $node instanceof Node\Expr\New_:
             return Expression::newExpression($this->parseNameNode($node->class), $this->parseNodes($node->args));
         case $node instanceof Node\Expr\MethodCall:
             return Expression::methodCall($this->parseNode($node->var), $this->parseNameNode($node->name), $this->parseNodes($node->args));
         case $node instanceof Node\Expr\PropertyFetch:
             return Expression::field($this->parseNode($node->var), $this->parseNameNode($node->name));
         case $node instanceof Node\Expr\ArrayDimFetch:
             return Expression::index($this->parseNode($node->var), $node->dim === null ? null : $this->parseNode($node->dim));
         case $node instanceof Node\Expr\ConstFetch:
             return Expression::constant($this->parseAbsoluteName($node->name));
         case $node instanceof Node\Expr\ClassConstFetch:
             return Expression::classConstant($this->parseNameNode($node->class), $node->name);
         case $node instanceof Node\Expr\StaticCall:
             return Expression::staticMethodCall($this->parseNameNode($node->class), $this->parseNameNode($node->name), $this->parseNodes($node->args));
         case $node instanceof Node\Expr\StaticPropertyFetch:
             return Expression::staticField($this->parseNameNode($node->class), $this->parseNameNode($node->name));
         case $node instanceof Node\Expr\Ternary:
             return $this->parseTernaryNode($node);
         case $node instanceof Node\Expr\Closure:
             return $this->parseClosureNode($node);
         case $node instanceof Node\Expr\Empty_:
             return Expression::emptyExpression($this->parseNode($node->expr));
         case $node instanceof Node\Expr\Isset_:
             return Expression::issetExpression($this->parseNodes($node->vars));
         default:
             throw new ASTException('Cannot parse AST with unknown expression node: %s', get_class($node));
     }
 }
Beispiel #3
0
 /**
  * @dataProvider parsers
  */
 public function testStaticField()
 {
     $this->assertParsedAs(function () {
         \Object::$field;
         Object::$field;
     }, [O\Expression::staticField(O\Expression::value('\\Object'), O\Expression::value('field')), O\Expression::staticField(O\Expression::value('\\' . __NAMESPACE__ . '\\Object'), O\Expression::value('field'))]);
 }