classSourceScanner
final class SourceScanner
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Finds the PHP files under the paths a run was pointed at.
Constants§
public const SKIPPED = ['vendor', 'node_modules', '.git', 'build']The directory names skipped unless a path names one directly.
Methods§
public function __construct(string $root, list<string> $excluded = [])Parameters
$root | string | The directory reported paths are relative to |
$excluded | list<string> | Patterns, matched against the reported path, to leave out |
Calls 1
- function-call
rtrimline 38
public function scan(list<string> $paths): list<SourceFile>The files under the given paths, in a stable order.
Parameters
$paths | list<string> |
Returns
list<SourceFile>Throws
SourceScanException When a path does not exist or cannot be readTest cases 2
Called from 1
Calls 3
- method-call SourceScanner::scanOne() line 53
- function-call
ksortline 57 - function-call
array_valuesline 59
public function scanOne(string $path): list<SourceFile>The files under one path.
Parameters
$path | string |
Returns
list<SourceFile>Throws
SourceScanException When the path does not exist or cannot be readTest cases 2
Called from 1
Calls 5
- function-call
is_fileline 70 - method-call SourceScanner::read() line 71
- function-call
is_dirline 75 - new SourceScanException line 76
- method-call SourceScanner::walk() line 80
public function walk(string $directory): list<string>Every PHP file under a directory, skipping the directories a scan never wants.
Parameters
$directory | string |
Returns
list<string>Test cases 1
Called from 1
Calls 9
- new
RecursiveIteratorIteratorline 97 - new
RecursiveCallbackFilterIteratorline 98 - new
RecursiveDirectoryIteratorline 99 - class-const
FilesystemIterator::SKIP_DOTS()line 99 - method-call
SplFileInfo::isDir()line 100 - function-call
in_arrayline 101 - method-call
SplFileInfo::getFilename()line 101 - class-const SourceScanner::SKIPPED() line 101
- function-call
sortline 111
public function read(string $path): ?SourceFileThe file read and named relative to the root, or null when it is excluded.
Parameters
$path | string |
Returns
Throws
SourceScanException When the file cannot be readTest cases 2
Called from 2
Calls 5
- method-call SourceScanner::relative() line 123
- method-call SourceScanner::isExcluded() line 124
- function-call
file_get_contentsline 127 - new SourceScanException line 129
- new SourceFile line 132
public function isExcluded(string $reported): boolWhether a reported path matches one of the exclusion patterns.
Parameters
$reported | string |
Returns
boolTest cases 1
Called from 1
public function relative(string $path): stringThe path as the catalog reports it.
Parameters
$path | string |
Returns
stringTest cases 1
Called from 1
Private surface 2§
Implementation details, listed for orientation only.
private string $rootprivate list<string> $excludedTest cases 11§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 9
SourceScannerTest::testIsExcludedAcceptsAPatternOrADirectorycallsSourceScannerTest::testReadNamesTheFileRelativeToTheRootcallsSourceScannerTest::testReadSkipsAnExcludedFilecallsSourceScannerTest::testRelativeLeavesAPathOutsideTheRootAlonecallsSourceScannerTest::testScanFindsThePhpFilesUnderADirectorycallsSourceScannerTest::testScanOneReadsASingleFilecallsSourceScannerTest::testScanOneRefusesAPathThatIsNotTherecallsSourceScannerTest::testScanReportsPathsInAStableOrdercallsSourceScannerTest::testWalkSkipsTheDirectoriesAScanNeverWantscalls
Other tests reaching this symbol 2
CatalogCommandTestcallsAnalyzerTestcalls