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);
}
}
}