mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-26 20:53:31 +00:00
6c20d257e3
d3d18d442c
keep relative paths
39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Caching;
|
|
|
|
use Rector\Caching\Detector\ChangedFilesDetector;
|
|
final class UnchangedFilesFilter
|
|
{
|
|
/**
|
|
* @readonly
|
|
* @var \Rector\Caching\Detector\ChangedFilesDetector
|
|
*/
|
|
private $changedFilesDetector;
|
|
public function __construct(ChangedFilesDetector $changedFilesDetector)
|
|
{
|
|
$this->changedFilesDetector = $changedFilesDetector;
|
|
}
|
|
/**
|
|
* @param string[] $filePaths
|
|
* @return string[]
|
|
*/
|
|
public function filterAndJoinWithDependentFileInfos(array $filePaths) : array
|
|
{
|
|
$changedFileInfos = [];
|
|
$dependentFileInfos = [];
|
|
foreach ($filePaths as $filePath) {
|
|
if (!$this->changedFilesDetector->hasFileChanged($filePath)) {
|
|
continue;
|
|
}
|
|
$changedFileInfos[] = $filePath;
|
|
$this->changedFilesDetector->invalidateFile($filePath);
|
|
$dependentFileInfos = \array_merge($dependentFileInfos, $this->changedFilesDetector->getDependentFilePaths($filePath));
|
|
}
|
|
// add dependent files
|
|
$dependentFileInfos = \array_merge($dependentFileInfos, $changedFileInfos);
|
|
return \array_unique($dependentFileInfos);
|
|
}
|
|
}
|