sourceFiles() as $file) { foreach (file($file) as $no => $line) { $trimmed = ltrim($line); if ($trimmed === '' || $trimmed[0] === '*' || str_starts_with($trimmed, '//') || str_starts_with($trimmed, '#') || str_starts_with($trimmed, '/*')) { continue; } if (preg_match($pattern, $line, $m)) { $violations[] = substr($file, strlen(MAIN_HOME)) . ':' . ($no + 1) . " → '{$m[1]}/' " . trim($line); } } } $this->assertSame( [], $violations, "Lowercase require/include paths to renamed dirs:\n" . implode("\n", $violations) ); } /** @return iterable absolute paths of every .php under src/ except vendor/tmp/backups. */ private function sourceFiles(): iterable { $it = new RecursiveIteratorIterator( new RecursiveCallbackFilterIterator( new RecursiveDirectoryIterator(MAIN_HOME, FilesystemIterator::SKIP_DOTS), static function (SplFileInfo $current): bool { $name = $current->getFilename(); if ($current->isDir()) { return !in_array($name, ['vendor', 'tmp', 'backups'], true); } return str_ends_with($name, '.php'); } ) ); foreach ($it as $file) { yield $file->getPathname(); } } }