Skip to content

Commit 047d814

Browse files
committed
Fix an undefined class error running gen_stub in php8
For whatever reason, php 8 would not have loaded the subsequent classes when running `php build/gen_stub.php path/to/filename.php`. I assume it didn't load the classes immediately because there's a possibility the code before it would throw. (Probably because __toString was added recently and prevents early binding) Also, fix a typo Closes GH-5369
1 parent 7b2a8a6 commit 047d814

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

build/Makefile.global

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ prof-clean:
142142
prof-use:
143143
CCACHE_DISABLE=1 $(MAKE) PROF_FLAGS=-fprofile-use all
144144

145-
# olny php above 7.1.0 supports nullable return type
145+
# only php above 7.1.0 supports nullable return type
146146
%_arginfo.h: %.stub.php
147147
@if test -e "$(top_srcdir)/build/gen_stub.php"; then \
148148
if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \

build/gen_stub.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,6 @@ protected function pName_FullyQualified(Name\FullyQualified $node) {
2626
}
2727
}
2828

29-
if ($argc >= 2) {
30-
if (is_file($argv[1])) {
31-
// Generate single file.
32-
processStubFile($argv[1]);
33-
} else if (is_dir($argv[1])) {
34-
processDirectory($argv[1]);
35-
} else {
36-
echo "$argv[1] is neither a file nor a directory.\n";
37-
exit(1);
38-
}
39-
} else {
40-
// Regenerate all stub files we can find.
41-
processDirectory('.');
42-
}
43-
4429
function processDirectory(string $dir) {
4530
$it = new RecursiveIteratorIterator(
4631
new RecursiveDirectoryIterator($dir),
@@ -1044,3 +1029,18 @@ function initPhpParser() {
10441029
}
10451030
});
10461031
}
1032+
1033+
if ($argc >= 2) {
1034+
if (is_file($argv[1])) {
1035+
// Generate single file.
1036+
processStubFile($argv[1]);
1037+
} else if (is_dir($argv[1])) {
1038+
processDirectory($argv[1]);
1039+
} else {
1040+
echo "$argv[1] is neither a file nor a directory.\n";
1041+
exit(1);
1042+
}
1043+
} else {
1044+
// Regenerate all stub files we can find.
1045+
processDirectory('.');
1046+
}

0 commit comments

Comments
 (0)