/**
  * {@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)
 {
     // -4, one for count to index, 3 because min. of tokens for a classy location.
     for ($index = $tokens->getSize() - 4; $index > 0; --$index) {
         if ($tokens[$index]->isClassy()) {
             $this->fixClassyDefinition($tokens, $index);
         }
     }
 }
 /**
  * {@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;
     $this->tokensAnalyzer = new TokensAnalyzer($this->tokens);
     for ($index = $tokens->getSize() - 1; $index > 0; --$index) {
         $this->fixByToken($tokens[$index], $index);
     }
 }
 /**
  * Find the index where the header comment must be inserted.
  *
  * @param Tokens $tokens
  *
  * @return int
  */
 private function findHeaderCommentInsertionIndex(Tokens $tokens)
 {
     $index = $tokens->getNextNonWhitespace(0);
     if (null === $index) {
         // empty file, insert at the end
         $index = $tokens->getSize();
     }
     return $index;
 }