Skip to content

Instantly share code, notes, and snippets.

@alister
Created September 7, 2019 12:56
Show Gist options
  • Save alister/88a72240aeace3666bb0bece0a04c00e to your computer and use it in GitHub Desktop.
Save alister/88a72240aeace3666bb0bece0a04c00e to your computer and use it in GitHub Desktop.
Find phpunit.xml* files, not in specific sub-dirs, esp not vendors/
<?php
use Symfony\Component\Finder\Finder;
require 'vendor/autoload.php';
$excludeDirs = [
'assets',
'bin',
'bower_components',
'build',
'docs',
'features',
'log',
'var',
'node_modules',
'vendor',
'web',
'.rules',
'tmp-phpqa',
'app/',
'src/*',
'templates',
'tests/',
];
// echo "Looking for phpunit.xml* files in ", __DIR__, PHP_EOL;
$finder = new Finder();
$finder->files()
->in(__DIR__)
->files()
->name('phpunit.xml*')
->exclude($excludeDirs)
->notPath($excludeDirs)
->ignoreUnreadableDirs()
->ignoreVCS(true)
->ignoreVCSIgnored(true)
;
if (!$finder->hasResults()) {
echo "no files found.", PHP_EOL;
exit;
}
foreach ($finder as $file) {
$fileNameWithExtension = $file->getRelativePathname();
echo $file->getPath(), ',', $file->getRealPath(), PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment