private function findHeaderCommentInsertionIndex(Tokens $tokens) { $index = $tokens->getNextNonWhitespace(0); if (null === $index) { $index = $tokens->getSize(); } return $index; }
/** * {@inheritdoc} */ public function fix(\SplFileInfo $file, Tokens $tokens) { for ($index = $tokens->getSize() - 1; $index > 0; --$index) { if (!$tokens[$index]->isClassy()) { continue; } $this->fixClassDefinition($tokens, $index, $tokens->getNextTokenOfKind($index, array('{'))); } }
/** * {@inheritdoc} */ public function fix(SplFileInfo $file, Tokens $tokens) { $tokensAnalyzer = new TokensAnalyzer($tokens); for ($index = $tokens->getSize() - 1; $index > 0; --$index) { if (!$tokens[$index]->isClassy()) { continue; } // figure out where the classy starts $classStart = $tokens->getNextTokenOfKind($index, array('{')); // figure out where the classy ends $classEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $classStart); if ($tokens[$index]->isGivenKind(T_INTERFACE)) { $this->fixInterface($tokens, $classStart, $classEnd); } else { // classes and traits can be fixed the same way $this->fixClass($tokens, $tokensAnalyzer, $classStart, $classEnd); } } }
/** * {@inheritdoc} */ public function fix(\SplFileInfo $file, Tokens $tokens) { $this->tokens = $tokens; for ($index = $tokens->getSize() - 1; $index > 0; --$index) { $this->fixByToken($tokens[$index], $index); } }