mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-13 14:42:23 +00:00
* re-enable rectify and ecs * [Rectify] [Php81] Enable Rectify on Readonly Property only * comment * [ci-review] Rector Rectify * [ci-review] Rector Rectify * [ci-review] Rector Rectify * [ci-review] Rector Rectify * [ci-review] Rector Rectify Co-authored-by: GitHub Action <action@github.com>
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Rector\Caching;
|
|
|
|
use Rector\Caching\Detector\ChangedFilesDetector;
|
|
use Symplify\SmartFileSystem\SmartFileInfo;
|
|
|
|
final class UnchangedFilesFilter
|
|
{
|
|
public function __construct(
|
|
private readonly ChangedFilesDetector $changedFilesDetector
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* @param SmartFileInfo[] $fileInfos
|
|
* @return SmartFileInfo[]
|
|
*/
|
|
public function filterAndJoinWithDependentFileInfos(array $fileInfos): array
|
|
{
|
|
$changedFileInfos = [];
|
|
$dependentFileInfos = [];
|
|
|
|
foreach ($fileInfos as $fileInfo) {
|
|
if (! $this->changedFilesDetector->hasFileChanged($fileInfo)) {
|
|
continue;
|
|
}
|
|
|
|
$changedFileInfos[] = $fileInfo;
|
|
$this->changedFilesDetector->invalidateFile($fileInfo);
|
|
|
|
$dependentFileInfos = array_merge(
|
|
$dependentFileInfos,
|
|
$this->changedFilesDetector->getDependentFileInfos($fileInfo)
|
|
);
|
|
}
|
|
|
|
// add dependent files
|
|
$dependentFileInfos = array_merge($dependentFileInfos, $changedFileInfos);
|
|
|
|
return array_unique($dependentFileInfos);
|
|
}
|
|
}
|