Skip to content

Commit

Permalink
Updated Rector to commit f2d4be8e1dd848ad2a00ea9b4af8511761f622d0
Browse files Browse the repository at this point in the history
rectorphp/rector-src@f2d4be8 [FileSystem] Move filter <?= on last for files filter to make consistent with filter in directories for performance (#6073)
  • Loading branch information
TomasVotruba committed Jun 28, 2024
1 parent bd04bc4 commit 77a7a17
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'b390886e366b6ed336d7c023e7fe3871d07c47f9';
public const PACKAGE_VERSION = 'f2d4be8e1dd848ad2a00ea9b4af8511761f622d0';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-06-29 00:25:13';
public const RELEASE_DATE = '2024-06-29 01:03:57';
/**
* @var int
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Caching/UnchangedFilesFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ public function __construct(ChangedFilesDetector $changedFilesDetector)
public function filterFilePaths(array $filePaths) : array
{
$changedFileInfos = [];
$filePaths = \array_unique($filePaths);
foreach ($filePaths as $filePath) {
if (!$this->changedFilesDetector->hasFileChanged($filePath)) {
continue;
}
$changedFileInfos[] = $filePath;
$this->changedFilesDetector->invalidateFile($filePath);
}
return \array_unique($changedFileInfos);
return $changedFileInfos;
}
}
16 changes: 10 additions & 6 deletions src/FileSystem/FilesFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,9 @@ public function __construct(\Rector\FileSystem\FilesystemTweaker $filesystemTwea
public function findInDirectoriesAndFiles(array $source, array $suffixes = [], bool $sortByName = \true) : array
{
$filesAndDirectories = $this->filesystemTweaker->resolveWithFnmatch($source);
$files = $this->fileAndDirectoryFilter->filterFiles($filesAndDirectories);
// exclude short "<?=" tags as lead to invalid changes
$files = \array_filter($files, function (string $file) : bool {
return !$this->isStartWithShortPHPTag(FileSystem::read($file));
});
$filteredFilePaths = \array_filter($files, function (string $filePath) : bool {
// filtering files in files collection
$filteredFilePaths = $this->fileAndDirectoryFilter->filterFiles($filesAndDirectories);
$filteredFilePaths = \array_filter($filteredFilePaths, function (string $filePath) : bool {
return !$this->pathSkipper->shouldSkip($filePath);
});
if ($suffixes !== []) {
Expand All @@ -62,11 +59,18 @@ public function findInDirectoriesAndFiles(array $source, array $suffixes = [], b
};
$filteredFilePaths = \array_filter($filteredFilePaths, $fileWithExtensionsFilter);
}
$filteredFilePaths = \array_filter($filteredFilePaths, function (string $file) : bool {
return !$this->isStartWithShortPHPTag(FileSystem::read($file));
});
// filtering files in directories collection
$directories = $this->fileAndDirectoryFilter->filterDirectories($filesAndDirectories);
$filteredFilePathsInDirectories = $this->findInDirectories($directories, $suffixes, $sortByName);
$filePaths = \array_merge($filteredFilePaths, $filteredFilePathsInDirectories);
return $this->unchangedFilesFilter->filterFilePaths($filePaths);
}
/**
* Exclude short "<?=" tags as lead to invalid changes
*/
private function isStartWithShortPHPTag(string $fileContent) : bool
{
return \strncmp(\ltrim($fileContent), '<?=', \strlen('<?=')) === 0;
Expand Down

0 comments on commit 77a7a17

Please sign in to comment.