From e3bfa69c53ca0b731553fe1e321e8033a1d08075 Mon Sep 17 00:00:00 2001 From: Tyson Andre Date: Sun, 20 Jun 2021 11:01:50 -0400 Subject: [PATCH] Allow build/gen_stub.php to process multiple CLI file args E.g. `build/gen_stub.php *.stub.php` will generate `*_arginfo.h` from multiple files. Previously, gen_stub.php would silently ignore files after the first file. Invoking gen_stub.php with no arguments will continue to process the entire directory. --- build/gen_stub.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 30d1eac28f0c9..88ece28deb721 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -2311,18 +2311,20 @@ function initPhpParser() { } $fileInfos = []; -$location = $argv[$optind] ?? "."; -if (is_file($location)) { - // Generate single file. - $fileInfo = processStubFile($location, $context); - if ($fileInfo) { - $fileInfos[] = $fileInfo; - } -} else if (is_dir($location)) { - $fileInfos = processDirectory($location, $context); -} else { - echo "$location is neither a file nor a directory.\n"; - exit(1); +$locations = array_slice($argv, $optind) ?: ['.']; +foreach (array_unique($locations) as $location) { + if (is_file($location)) { + // Generate single file. + $fileInfo = processStubFile($location, $context); + if ($fileInfo) { + $fileInfos[] = $fileInfo; + } + } else if (is_dir($location)) { + array_push($fileInfos, ...processDirectory($location, $context)); + } else { + echo "$location is neither a file nor a directory.\n"; + exit(1); + } } if ($printParameterStats) {