public function getNextNonWhitespace(Token $token) { for ($i = $token->getIndex() + 1, $count = $this->count(); $i < $count; $i += 1) { if (!$this[$i]->is(T_WHITESPACE)) { return $this[$i]; } } return null; }
private function normalizeTokens(array $tokens) { $position = 0; $tokenObjects = array(); foreach ($tokens as $i => &$token) { $previousToken = 0 == $i ? null : $tokens[$i - 1]; $originalToken = $token; if (is_string($token)) { $token = array(0 => $token, 1 => $token, 2 => 0 == $i ? 0 : $previousToken[2]); } switch ($token[0]) { case '{': case '}': case '(': case ')': $tokenObject = new BracketToken(); break; case T_NAMESPACE: $tokenObject = new NamespaceToken(); break; case T_CONST: $tokenObject = new ConstantToken(); break; default: $tokenObject = new Token(); } $tokenObject->setTypeIndex($token[0]); $tokenObject->setContent($token[1]); $tokenObject->setLine($token[2]); $tokenObject->setTypeName(is_int($tokenObject->getTypeIndex()) ? token_name($tokenObject->getTypeIndex()) : $tokenObject->getContent()); $tokenObject->setPosition($position); $tokenObject->setIndex($i); $tokenObject->setOriginalToken($originalToken); $tokenObjects[] = $tokenObject; $position += strlen($tokenObject->getContent()); } return $tokenObjects; }