![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/rector/rector/src/StaticReflection/ |
<?php declare (strict_types=1); namespace Rector\Core\StaticReflection; use Rector\Core\FileSystem\FileAndDirectoryFilter; use Rector\Core\FileSystem\FilesystemTweaker; use Rector\Core\FileSystem\PhpFilesFinder; 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 class DynamicSourceLocatorDecorator { /** * @readonly * @var \Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider */ private $dynamicSourceLocatorProvider; /** * @readonly * @var \Rector\Core\FileSystem\PhpFilesFinder */ private $phpFilesFinder; /** * @readonly * @var \Rector\Core\FileSystem\FileAndDirectoryFilter */ private $fileAndDirectoryFilter; /** * @readonly * @var \Rector\Core\FileSystem\FilesystemTweaker */ private $filesystemTweaker; public function __construct(DynamicSourceLocatorProvider $dynamicSourceLocatorProvider, PhpFilesFinder $phpFilesFinder, FileAndDirectoryFilter $fileAndDirectoryFilter, FilesystemTweaker $filesystemTweaker) { $this->dynamicSourceLocatorProvider = $dynamicSourceLocatorProvider; $this->phpFilesFinder = $phpFilesFinder; $this->fileAndDirectoryFilter = $fileAndDirectoryFilter; $this->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); foreach ($directories as $directory) { $filesInDirectory = $this->phpFilesFinder->findInPaths([$directory]); $this->dynamicSourceLocatorProvider->addFilesByDirectory($directory, $filesInDirectory); } } public function isPathsEmpty() : bool { return $this->dynamicSourceLocatorProvider->isPathsEmpty(); } }