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) {