PhpCsFixer\Runner\Runner::fix PHP Method

fix() public method

public fix ( ) : array
return array
    public function fix()
    {
        $changed = array();
        $finder = $this->finder;
        $finderIterator = $finder instanceof \IteratorAggregate ? $finder->getIterator() : $finder;
        $fileFilteredFileIterator = new FileFilterIterator($finderIterator, $this->eventDispatcher, $this->cacheManager);
        $collection = $this->linter->isAsync() ? new FileCachingLintingIterator($fileFilteredFileIterator, $this->linter) : new FileLintingIterator($fileFilteredFileIterator, $this->linter);
        foreach ($collection as $file) {
            $fixInfo = $this->fixFile($file, $collection->currentLintingResult());
            if ($fixInfo) {
                $name = $this->getFileRelativePathname($file);
                $changed[$name] = $fixInfo;
            }
            // we do not need Tokens to still caching just fixed file - so clear the cache
            Tokens::clearCache();
        }
        return $changed;
    }

Usage Example

Esempio n. 1
0
 public function testCanFixWithConfigInterfaceImplementation()
 {
     $config = $this->getMockBuilder('PhpCsFixer\\ConfigInterface')->getMock();
     $config->expects($this->any())->method('getFixers')->willReturn(array());
     $config->expects($this->any())->method('getRules')->willReturn(array());
     $config->expects($this->any())->method('getFinder')->willReturn(new \ArrayIterator(array()));
     $runner = new Runner($config, new NullDiffer(), null, new ErrorsManager(), new NullLinter(), true);
     $runner->fix();
 }
All Usage Examples Of PhpCsFixer\Runner\Runner::fix