public function skipUntil($matcher) { while ($this->moveNext()) { if ($this->token->matches($matcher)) { return $this->token; } } return null; }
private function isSafeEndToken(AbstractToken $token) { $nextNoWhitespace = $token->findNextToken('NO_WHITESPACE')->get(); // If the end token is followed by a comment on the same same line, // we consider it unsafe for rewriting. if ($nextNoWhitespace->matches('COMMENT') && $token->getLine() === $nextNoWhitespace->getLine()) { return false; } return true; }
public function isIgnored(AbstractToken $token) { if ($this->ignoreComments && $token->isComment()) { return true; } if ($this->ignoreWhitespace && $token->isWhitespace()) { return true; } return false; }
private function checkLeftCurlyPlacement(AbstractToken $startToken, AbstractToken $endToken, AbstractToken $curlyToken, $config) { if ('new line on wrap' === $config) { $config = $startToken->getLine() === $endToken->getLine() ? 'same line' : 'new line'; } switch ($config) { case 'same line': if ($endToken->getLine() !== $curlyToken->getLine()) { $this->phpFile->addComment($curlyToken->getLine(), Comment::warning('coding_style.token_should_be_on_same_line', '``%token%`` should probably be on the same line like ``%end_token%``.', array('token' => $curlyToken->getContent(), 'end_token' => $endToken->getContent()))->varyIn(array())); } break; case 'new line': if ($endToken->getLine() + 1 !== $curlyToken->getLine()) { $this->phpFile->addComment($curlyToken->getLine(), Comment::warning('coding_style.token_should_be_on_new_line', '``%token`` should probably be on a new line after ``%end_token%``.', array('token' => $curlyToken->getContent(), 'end_token' => $endToken->getContent()))->varyIn(array())); } break; default: throw new \InvalidArgumentException(sprintf('Unknown left curly setting "%s".', $config)); } }