public function __construct(SourceBuffer $buffer) { $this->id = $buffer->getId(); $this->buffer = $buffer; }
/** * Read the next name from the stream (a name is of type T_STRING and may be a concatenation of * the form "T_NS_SEPARATOR? T_STRING (T_NS_SEPARATOR T_STRING)*"). * * @param SourceBuffer $generator * @param boolean $skipSpace * @return string The (qualified) name or false if no name was found. */ public function nextName(SourceBuffer $generator, $skipSpace = true) { $name = ''; while (true) { if (isset($this->tokens[$this->index]) && is_array($this->tokens[$this->index])) { if ($name == '') { switch ($this->tokens[$this->index][0]) { case T_COMMENT: case T_DOC_COMMENT: case T_CONSTANT_ENCAPSED_STRING: $generator->append($this->tokens[$this->index]); $this->index++; continue 2; case T_WHITESPACE: if ($skipSpace) { $generator->append($this->tokens[$this->index]); $this->index++; continue 2; } break; case T_STRING: case T_NS_SEPARATOR: $name .= $this->tokens[$this->index++][1]; continue 2; } } else { switch ($this->tokens[$this->index][0]) { case T_STRING: case T_NS_SEPARATOR: $name .= $this->tokens[$this->index++][1]; continue 2; } } } break; } return $name == '' ? false : $name; }