Skip to content

Commit e748dca

Browse files
authored
Allow build/gen_stub.php to process multiple CLI file args (php#7179)
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.
1 parent 28a1a6b commit e748dca

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

build/gen_stub.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,18 +2311,20 @@ function initPhpParser() {
23112311
}
23122312

23132313
$fileInfos = [];
2314-
$location = $argv[$optind] ?? ".";
2315-
if (is_file($location)) {
2316-
// Generate single file.
2317-
$fileInfo = processStubFile($location, $context);
2318-
if ($fileInfo) {
2319-
$fileInfos[] = $fileInfo;
2320-
}
2321-
} else if (is_dir($location)) {
2322-
$fileInfos = processDirectory($location, $context);
2323-
} else {
2324-
echo "$location is neither a file nor a directory.\n";
2325-
exit(1);
2314+
$locations = array_slice($argv, $optind) ?: ['.'];
2315+
foreach (array_unique($locations) as $location) {
2316+
if (is_file($location)) {
2317+
// Generate single file.
2318+
$fileInfo = processStubFile($location, $context);
2319+
if ($fileInfo) {
2320+
$fileInfos[] = $fileInfo;
2321+
}
2322+
} else if (is_dir($location)) {
2323+
array_push($fileInfos, ...processDirectory($location, $context));
2324+
} else {
2325+
echo "$location is neither a file nor a directory.\n";
2326+
exit(1);
2327+
}
23262328
}
23272329

23282330
if ($printParameterStats) {

0 commit comments

Comments
 (0)