classFinder
final class Finder
@visibility public.Finds local file paths without reading or parsing their contents. Patterns match paths relative to each root: * and ? stay within a component. The recursive ** wildcard crosses directories and can match zero directories. Exclusions win. Linked files and directories are skipped. With no roots, searches the current directory; with no includes, selects every regular file. No directories are excluded implicitly.
$finder = (new \Deriver\Finder())->in(__DIR__)->include('*.php')->exclude('vendor');
is_array($finder->files()) // => trueMethods§
public function in(string $directory, string ...$directories): selfAdds local search roots. Results are sorted, unique absolute paths.
Parameters
$directory | string | |
$directories | string |
Returns
selfThrows
InvalidInputException If a root is not a readable local directoryTest cases 11
CliBench::locateWithEvaluatorscallsLaravelBench::locateWithEvaluatorscallsSymfonyBench::locateWithEvaluatorscallsWebBench::locateWithEvaluatorscallsFinderTest::testEnumerationDoesNotRequireReadAccessToFileContentscallsFinderTest::testExcludeWinsAfterCombiningIncludesRegardlessOfCallOrdercallsFinderTest::testFilesApplyIncludesAndExcludesWithoutReadingPhpcallsFinderTest::testIncludeWildcardsRespectDirectoriesAndMatchZeroOrManyLevelscallsFinderTest::testInCombinesOverlappingRootsIntoSortedUniqueAbsolutePathscallsFinderTest::testRejectsInvalidRootscallsFinderTest::testRepeatedEnumerationSeesNewFilescalls
Called from 1
public function include(string $pattern, string ...$patterns): selfIncludes files matching any supplied root-relative wildcard pattern.
Parameters
$pattern | string | |
$patterns | string |
Returns
selfCalled from 1
Calls 1
- new PathPattern line 62
public function exclude(string $pattern, string ...$patterns): selfExcludes matching files and directory subtrees, even when included explicitly.
Parameters
$pattern | string | |
$patterns | string |
Returns
selfCalled from 1
Calls 1
- new PathPattern line 73
public function files(): list<string>Enumerates paths only; file contents are read later by Deriver::prepare().
Returns
list<string> Sorted, unique absolute pathsCalled from 1
Calls 7
- method-call
self::in()line 84 - new
selfline 84 - function-call
array_uniqueline 86 - method-call DirectoryScan::files() line 87
- new DirectoryScan line 87
- function-call
array_keysline 91 - function-call
sortline 92
Private surface 3§
Implementation details, listed for orientation only.
private list<string> $directories = []private list<PathPattern> $includes = []private list<PathPattern> $excludes = []Test cases 12§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
FinderTest::testDefaultsUseCurrentDirectoryAndDoNotImplicitlyExcludeFilescallsFinderTest::testEnumerationDoesNotRequireReadAccessToFileContentscallsFinderTest::testExcludeWinsAfterCombiningIncludesRegardlessOfCallOrdercallsFinderTest::testFilesApplyIncludesAndExcludesWithoutReadingPhpcallsFinderTest::testIncludeWildcardsRespectDirectoriesAndMatchZeroOrManyLevelscallsFinderTest::testInCombinesOverlappingRootsIntoSortedUniqueAbsolutePathscallsFinderTest::testRejectsInvalidRootscallsFinderTest::testRepeatedEnumerationSeesNewFilescalls
Other tests reaching this symbol 4
Relations§
Instantiated in 1
Method calls 4
- method-call Deriver\Command\DeriveCommand::execute() packages/deriver/src/Command/DeriveCommand.php:71
- method-call Deriver\Command\DeriveCommand::execute() packages/deriver/src/Command/DeriveCommand.php:74
- method-call Deriver\Command\DeriveCommand::execute() packages/deriver/src/Command/DeriveCommand.php:77
- method-call Deriver\Command\DeriveCommand::execute() packages/deriver/src/Command/DeriveCommand.php:79