From 047d8147047b319feca477ff4ba28ca5a2426a05 Mon Sep 17 00:00:00 2001 From: Tyson Andre Date: Sat, 11 Apr 2020 16:52:47 -0400 Subject: [PATCH] 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 --- build/Makefile.global | 2 +- build/gen_stub.php | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/build/Makefile.global b/build/Makefile.global index 7b5d2a4919..237308d265 100644 --- a/build/Makefile.global +++ b/build/Makefile.global @@ -142,7 +142,7 @@ prof-clean: prof-use: CCACHE_DISABLE=1 $(MAKE) PROF_FLAGS=-fprofile-use all -# olny php above 7.1.0 supports nullable return type +# only php above 7.1.0 supports nullable return type %_arginfo.h: %.stub.php @if test -e "$(top_srcdir)/build/gen_stub.php"; then \ if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \ diff --git a/build/gen_stub.php b/build/gen_stub.php index 02a035debd..b108191f64 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -26,21 +26,6 @@ class CustomPrettyPrinter extends Standard } } -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($dir), @@ -1044,3 +1029,18 @@ function initPhpParser() { } }); } + +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('.'); +} -- 2.40.0