MediaWiki master
PhpUnitTestFileScanner.php
Go to the documentation of this file.
1<?php
2
3declare( strict_types = 1 );
4
6
7use RecursiveDirectoryIterator;
8use RecursiveIteratorIterator;
9
14
15 private string $rootDir;
16
17 public function __construct( string $rootDir ) {
18 $this->rootDir = $rootDir;
19 }
20
28 public function scanForFiles(): array {
29 $phpFiles = [];
30 $iterator = new RecursiveIteratorIterator(
32 new RecursiveDirectoryIterator( $this->rootDir )
33 )
34 );
35 foreach ( $iterator as $file ) {
36 if ( $file->isFile() && $file->getExtension() === 'php' ) {
37 $filename = $file->getFilename();
38 if ( !array_key_exists( $filename, $phpFiles ) ) {
39 $phpFiles[$filename] = [];
40 }
41 $phpFiles[$filename][] = $file->getPathname();
42 }
43 }
44 return $phpFiles;
45 }
46}