public function fixFile(\SplFileInfo $file, array $fixers, $dryRun, $diff) { if ($this->stopwatch) { $this->stopwatch->start($this->getFileRelativePathname($file)); } $new = $old = file_get_contents($file->getRealpath()); $appliedFixers = array(); // we do not need Tokens to still caching previously fixed file - so clear the cache Tokens::clearCache(); foreach ($fixers as $fixer) { if (!$fixer->supports($file)) { continue; } $newest = $fixer->fix($file, $new); if ($newest !== $new) { $appliedFixers[] = $fixer->getName(); } $new = $newest; } $fixInfo = null; if ($new !== $old) { if (!$dryRun) { file_put_contents($file->getRealpath(), $new); } $fixInfo = array('appliedFixers' => $appliedFixers); if ($diff) { $fixInfo['diff'] = $this->stringDiff($old, $new); } } if ($this->stopwatch) { $this->stopwatch->stop($this->getFileRelativePathname($file)); } return $fixInfo; }