/** * Constructs an encapsed string node. * * @param array $parts Encaps list * @param array $attributes Additional attributes */ public function __construct(array $parts, array $attributes = array()) { parent::__construct($attributes); $this->parts = $parts; }
/** * Constructs an integer number scalar node. * * @param int $value Value of the number * @param array $attributes Additional attributes */ public function __construct($value = 0, array $attributes = array()) { parent::__construct(null, $attributes); $this->value = $value; }
/** * Constructs a magic constant node. * * @param array $attributes Additional attributes */ public function __construct(array $attributes = array()) { parent::__construct(array(), $attributes); }
/** * Constructs a float number scalar node. * * @param float $value Value of the number * @param array $attributes Additional attributes */ public function __construct($value = 0.0, array $attributes = array()) { parent::__construct(array('value' => $value), $attributes); }
/** * Constructs a fake node. * * @param mixed $value Value of the Node * @param mixed $type Type of the node * @param array $attributes Additional attributes */ public function __construct($value, $type, array $attributes = array()) { parent::__construct($attributes); $this->value = $value; $this->type = $type; }
private function parseScalarNode(Node\Scalar $node) { switch (true) { case $node instanceof Node\Scalar\DNumber: case $node instanceof Node\Scalar\LNumber: case $node instanceof Node\Scalar\String_: return Expression::value($node->value); case $node instanceof Node\Scalar\MagicConst\Line: return Expression::value($node->getAttribute('startLine')); case $node instanceof Node\Scalar\MagicConst: return Expression::constant($node->getName()); default: return; } }
private function parseScalarNode(Node\Scalar $scalar) { switch ($scalar->getType()) { case 'Scalar_Encapsed': $op = new Op\Expr\ConcatList($this->parseExprList($scalar->parts, self::MODE_READ), $this->mapAttributes($scalar)); $this->block->children[] = $op; return $op->result; case 'Scalar_DNumber': case 'Scalar_LNumber': case 'Scalar_String': case 'Scalar_EncapsedStringPart': return new Literal($scalar->value); case 'Scalar_MagicConst_Class': // TODO return new Literal("__CLASS__"); case 'Scalar_MagicConst_Dir': return new Literal(dirname($this->fileName)); case 'Scalar_MagicConst_File': return new Literal($this->fileName); case 'Scalar_MagicConst_Namespace': // TODO return new Literal("__NAMESPACE__"); case 'Scalar_MagicConst_Method': // TODO return new Literal("__METHOD__"); case 'Scalar_MagicConst_Function': // TODO return new Literal("__FUNCTION__"); default: throw new \RuntimeException("Unknown how to deal with scalar type " . $scalar->getType()); } }
/** * Constructs an encapsed string node. * * @param array $parts Encaps list * @param array $attributes Additional attributes */ public function __construct(array $parts = array(), array $attributes = array()) { parent::__construct(array('parts' => $parts), $attributes); }