-
-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathDynamicSourceLocatorDecorator.php
More file actions
46 lines (37 loc) · 1.32 KB
/
DynamicSourceLocatorDecorator.php
File metadata and controls
46 lines (37 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
declare(strict_types=1);
namespace Rector\StaticReflection;
use Rector\FileSystem\FileAndDirectoryFilter;
use Rector\FileSystem\FilesystemTweaker;
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider;
/**
* @see https://phpstan.org/blog/zero-config-analysis-with-static-reflection
* @see https://github.com/rectorphp/rector/issues/3490
*/
final readonly class DynamicSourceLocatorDecorator
{
public function __construct(
private DynamicSourceLocatorProvider $dynamicSourceLocatorProvider,
private FileAndDirectoryFilter $fileAndDirectoryFilter,
private FilesystemTweaker $filesystemTweaker
) {
}
/**
* @param string[] $paths
*/
public function addPaths(array $paths): void
{
if ($paths === []) {
return;
}
$paths = $this->filesystemTweaker->resolveWithFnmatch($paths);
$files = $this->fileAndDirectoryFilter->filterFiles($paths);
$this->dynamicSourceLocatorProvider->addFiles($files);
$directories = $this->fileAndDirectoryFilter->filterDirectories($paths);
$this->dynamicSourceLocatorProvider->addDirectories($directories);
}
public function arePathsEmpty(): bool
{
return $this->dynamicSourceLocatorProvider->arePathsEmpty();
}
}