PhpCsFixer\Cache\FileCacheManager::needFixing PHP Метод

needFixing() публичный Метод

public needFixing ( $file, $fileContent )
    public function needFixing($file, $fileContent)
    {
        $file = $this->cacheDirectory->getRelativePathTo($file);
        return !$this->cache->has($file) || $this->cache->get($file) !== $this->calcHash($fileContent);
    }

Usage Example

 public function testNeedFixingUsesRelativePathToFile()
 {
     $cacheFile = $this->getFile();
     $file = '/foo/bar/baz/src/hello.php';
     $relativePathToFile = 'src/hello.php';
     $fileContent = '<?php echo "Hello!"';
     $directory = $this->getDirectoryMock();
     $directory->expects($this->once())->method('getRelativePathTo')->with($this->identicalTo($file))->willReturn($relativePathToFile);
     $cachedSignature = $this->getSignatureMock();
     $signature = $this->getSignatureMock();
     $signature->expects($this->once())->method('equals')->with($this->identicalTo($cachedSignature))->willReturn(true);
     $cache = $this->getCacheMock();
     $cache->expects($this->once())->method('getSignature')->willReturn($cachedSignature);
     $cache->expects($this->once())->method('has')->with($this->identicalTo($relativePathToFile))->willReturn(true);
     $cache->expects($this->once())->method('get')->with($this->identicalTo($relativePathToFile));
     $handler = $this->getFileHandlerMock();
     $handler->expects($this->never())->method('getFile')->willReturn($cacheFile);
     $handler->expects($this->once())->method('read')->willReturn($cache);
     $manager = new FileCacheManager($handler, $signature, false, $directory);
     $manager->needFixing($file, $fileContent);
 }