Allow generating stubs for directory

This commit is contained in:
Nikita Popov 2019-11-01 16:32:33 +01:00
parent 4008704f62
commit 5ca46572e6

View file

@ -15,12 +15,23 @@ try {
}
if ($argc >= 2) {
if (is_file($argv[1])) {
// Generate single file.
processStubFile($argv[1]);
} else if (is_dir($argv[1])) {
processDirectory($argv[1]);
} else {
echo "$argv[1] is neither a file nor a directory.\n";
exit(1);
}
} else {
// Regenerate all stub files we can find.
processDirectory('.');
}
function processDirectory(string $dir) {
$it = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator('.'),
new RecursiveDirectoryIterator($dir),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($it as $file) {