From f0c04ace75351564c156491b0840ee57685343f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Tue, 12 Mar 2024 08:40:57 +0100 Subject: [PATCH 1/2] Verify stub aliases in CI In the same time, let's not verify implementation aliases since they may now legitimately differ from their aliased function/method counterpart (think about the ext/dom refactoring). Additionally, unncessary `@no-verify` tags are cleaned up. --- .github/actions/verify-generated-files/action.yml | 5 ++--- build/gen_stub.php | 2 +- ext/bz2/bz2.stub.php | 3 --- ext/bz2/bz2_arginfo.h | 2 +- ext/mysqli/mysqli.stub.php | 3 --- ext/mysqli/mysqli_arginfo.h | 2 +- ext/phar/phar_object.stub.php | 7 +------ ext/phar/phar_object_arginfo.h | 2 +- ext/reflection/php_reflection.stub.php | 5 +---- ext/reflection/php_reflection_arginfo.h | 2 +- ext/spl/spl_observer.stub.php | 7 +------ ext/spl/spl_observer_arginfo.h | 5 +++-- ext/sqlite3/sqlite3.stub.php | 10 +++++----- ext/sqlite3/sqlite3_arginfo.h | 2 +- 14 files changed, 19 insertions(+), 38 deletions(-) diff --git a/.github/actions/verify-generated-files/action.yml b/.github/actions/verify-generated-files/action.yml index d4ca6301144c0..f926468637551 100644 --- a/.github/actions/verify-generated-files/action.yml +++ b/.github/actions/verify-generated-files/action.yml @@ -4,12 +4,11 @@ runs: steps: - shell: bash run: | - set -x + set -ex [[ "$OSTYPE" == "darwin"* ]] && export PATH="$(brew --prefix)/opt/bison/bin:$PATH" scripts/dev/credits scripts/dev/genfiles Zend/zend_vm_gen.php ext/tokenizer/tokenizer_data_gen.php - build/gen_stub.php -f - build/gen_stub.php --generate-optimizer-info + build/gen_stub.php -f --generate-optimizer-info --verify git add . -N && git diff --exit-code diff --git a/build/gen_stub.php b/build/gen_stub.php index 4715f7a401310..e427a358eb57c 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -5922,7 +5922,7 @@ function initPhpParser() { $errors = []; foreach ($funcMap as $aliasFunc) { - if (!$aliasFunc->alias) { + if (!$aliasFunc->alias || $aliasFunc->aliasType !== "alias") { continue; } diff --git a/ext/bz2/bz2.stub.php b/ext/bz2/bz2.stub.php index b1221847c6c8b..8d0f48fc96446 100644 --- a/ext/bz2/bz2.stub.php +++ b/ext/bz2/bz2.stub.php @@ -14,21 +14,18 @@ function bzread($bz, int $length = 1024): string|false {} /** * @param resource $bz * @implementation-alias fwrite - * @no-verify Uses different parameter name */ function bzwrite($bz, string $data, ?int $length = null): int|false {} /** * @param resource $bz * @implementation-alias fflush - * @no-verify Uses different parameter name */ function bzflush($bz): bool {} /** * @param resource $bz * @implementation-alias fclose - * @no-verify Uses different parameter name */ function bzclose($bz): bool {} diff --git a/ext/bz2/bz2_arginfo.h b/ext/bz2/bz2_arginfo.h index e7bde62684eb3..bac3b57023dcf 100644 --- a/ext/bz2/bz2_arginfo.h +++ b/ext/bz2/bz2_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: ebd3dc9902075c276828c17dc7a1c3bdc5401f8e */ + * Stub hash: c2c8e0fe1e3244c8cadafe60b65b7235c105b3c9 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_bzopen, 0, 0, 2) ZEND_ARG_INFO(0, file) diff --git a/ext/mysqli/mysqli.stub.php b/ext/mysqli/mysqli.stub.php index 4fd55442b7447..3def5adb61791 100644 --- a/ext/mysqli/mysqli.stub.php +++ b/ext/mysqli/mysqli.stub.php @@ -776,7 +776,6 @@ public function character_set_name(): string {} /** * @return true * @alias mysqli_close - * @no-verify */ public function close() {} // TODO make return type void @@ -989,7 +988,6 @@ public function set_opt(int $option, $value): bool {} /** * @return true * @alias mysqli_ssl_set - * @no-verify */ public function ssl_set( ?string $key, @@ -1242,7 +1240,6 @@ public function bind_result(mixed &...$vars): bool {} /** * @return true * @alias mysqli_stmt_close - * @no-verify */ public function close() {} // TODO make return type void diff --git a/ext/mysqli/mysqli_arginfo.h b/ext/mysqli/mysqli_arginfo.h index 470c71b1c97f0..e26e38cd511da 100644 --- a/ext/mysqli/mysqli_arginfo.h +++ b/ext/mysqli/mysqli_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: a54ef005e9535458e886b7845a25a1c742a114ac */ + * Stub hash: a8822bd2d34cadfd7c7e166cb7be38271ea3ae6a */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mysqli_affected_rows, 0, 1, MAY_BE_LONG|MAY_BE_STRING) ZEND_ARG_OBJ_INFO(0, mysql, mysqli, 0) diff --git a/ext/phar/phar_object.stub.php b/ext/phar/phar_object.stub.php index f39fdba5a48fe..27ee6a9cc8175 100644 --- a/ext/phar/phar_object.stub.php +++ b/ext/phar/phar_object.stub.php @@ -245,10 +245,7 @@ final public static function webPhar( class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAccess { - /** - * @implementation-alias Phar::__construct - * @no-verify PharData constructor accepts extra $format argument - */ + /** @implementation-alias Phar::__construct */ public function __construct(string $filename, int $flags = FilesystemIterator::SKIP_DOTS|FilesystemIterator::UNIX_PATHS, ?string $alias = null, int $format = 0) {} /** @implementation-alias Phar::__destruct */ @@ -299,14 +296,12 @@ public function decompressFiles() {} // TODO make return type void /** * @tentative-return-type * @implementation-alias Phar::compress - * @no-verify */ public function compress(int $compression, ?string $extension = null): ?PharData {} /** * @tentative-return-type * @implementation-alias Phar::decompress - * @no-verify */ public function decompress(?string $extension = null): ?PharData {} diff --git a/ext/phar/phar_object_arginfo.h b/ext/phar/phar_object_arginfo.h index fc149ba0ac693..1ee3a122708e2 100644 --- a/ext/phar/phar_object_arginfo.h +++ b/ext/phar/phar_object_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 00f5d4fc74e8b7dc67da6f12180c9fae343954cc */ + * Stub hash: 03ae11b93de6df5cfb494662f96a1474ddc2fd28 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) diff --git a/ext/reflection/php_reflection.stub.php b/ext/reflection/php_reflection.stub.php index 41768b6f61b20..944ae0ad9aeda 100644 --- a/ext/reflection/php_reflection.stub.php +++ b/ext/reflection/php_reflection.stub.php @@ -800,10 +800,7 @@ public function __construct(object|string $class, string $constant) {} public function getEnum(): ReflectionEnum {} - /** - * @implementation-alias ReflectionClassConstant::getValue - * @no-verify - */ + /** @implementation-alias ReflectionClassConstant::getValue */ public function getValue(): UnitEnum {} } diff --git a/ext/reflection/php_reflection_arginfo.h b/ext/reflection/php_reflection_arginfo.h index eaab1e8a786d5..05858203dfc04 100644 --- a/ext/reflection/php_reflection_arginfo.h +++ b/ext/reflection/php_reflection_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 0adb92be59fadce74bb12017fe64ffbccab2a060 */ + * Stub hash: f787e43effbd114daddad5d3ffcaf9faf7821d64 */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Reflection_getModifierNames, 0, 1, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO(0, modifiers, IS_LONG, 0) diff --git a/ext/spl/spl_observer.stub.php b/ext/spl/spl_observer.stub.php index 4fa2b08d64f7a..13247eea1199d 100644 --- a/ext/spl/spl_observer.stub.php +++ b/ext/spl/spl_observer.stub.php @@ -88,7 +88,6 @@ public function offsetGet($object): mixed {} * @param object $object * @tentative-return-type * @implementation-alias SplObjectStorage::attach - * @no-verify Cannot specify arg type because ArrayAccess does not */ public function offsetSet($object, mixed $info = null): void {} @@ -96,7 +95,6 @@ public function offsetSet($object, mixed $info = null): void {} * @param object $object * @tentative-return-type * @implementation-alias SplObjectStorage::detach - * @no-verify Cannot specify arg type because ArrayAccess does not */ public function offsetUnset($object): void {} @@ -159,9 +157,6 @@ public function current(): array {} /** @tentative-return-type */ public function next(): void {} - /** - * @tentative-return-type - * @implementation-alias SplObjectStorage::__debugInfo - */ + /** @tentative-return-type */ public function __debugInfo(): array {} } diff --git a/ext/spl/spl_observer_arginfo.h b/ext/spl/spl_observer_arginfo.h index b395897917711..10852247938c0 100644 --- a/ext/spl/spl_observer_arginfo.h +++ b/ext/spl/spl_observer_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 3e17e99dffb3150685ae7c4724d6b8aad2f5db6e */ + * Stub hash: 2d075036abecd043dbf5f3a2ab0c57f2d49e42f0 */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplObserver_update, 0, 1, IS_VOID, 0) ZEND_ARG_OBJ_INFO(0, subject, SplSubject, 0) @@ -166,6 +166,7 @@ ZEND_METHOD(MultipleIterator, valid); ZEND_METHOD(MultipleIterator, key); ZEND_METHOD(MultipleIterator, current); ZEND_METHOD(MultipleIterator, next); +ZEND_METHOD(MultipleIterator, __debugInfo); static const zend_function_entry class_SplObserver_methods[] = { ZEND_RAW_FENTRY("update", NULL, arginfo_class_SplObserver_update, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) @@ -220,7 +221,7 @@ static const zend_function_entry class_MultipleIterator_methods[] = { ZEND_ME(MultipleIterator, key, arginfo_class_MultipleIterator_key, ZEND_ACC_PUBLIC) ZEND_ME(MultipleIterator, current, arginfo_class_MultipleIterator_current, ZEND_ACC_PUBLIC) ZEND_ME(MultipleIterator, next, arginfo_class_MultipleIterator_next, ZEND_ACC_PUBLIC) - ZEND_RAW_FENTRY("__debugInfo", zim_SplObjectStorage___debugInfo, arginfo_class_MultipleIterator___debugInfo, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_ME(MultipleIterator, __debugInfo, arginfo_class_MultipleIterator___debugInfo, ZEND_ACC_PUBLIC) ZEND_FE_END }; diff --git a/ext/sqlite3/sqlite3.stub.php b/ext/sqlite3/sqlite3.stub.php index 8cb7f3a70a904..77a879abe2f04 100644 --- a/ext/sqlite3/sqlite3.stub.php +++ b/ext/sqlite3/sqlite3.stub.php @@ -272,13 +272,13 @@ class SQLite3 public const int RECURSIVE = UNKNOWN; #endif - /** - * @implementation-alias SQLite3::open - * @no-verify SQLite3::open should really be static - */ + /** @implementation-alias SQLite3::open */ public function __construct(string $filename, int $flags = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, string $encryptionKey = "") {} - /** @tentative-return-type */ + /** + * @tentative-return-type + * @todo SQLite3::open should really be static + */ public function open(string $filename, int $flags = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, string $encryptionKey = ""): void {} /** @return bool */ diff --git a/ext/sqlite3/sqlite3_arginfo.h b/ext/sqlite3/sqlite3_arginfo.h index bc3caf4096237..4618366f9bd69 100644 --- a/ext/sqlite3/sqlite3_arginfo.h +++ b/ext/sqlite3/sqlite3_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 6c5f8bc087baa56f40834f9745f3d0f22f60edba */ + * Stub hash: ec304d7a3db5b3a50c0d95755691bc055dffe047 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SQLite3___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) From 7c337fb789c0fe2cda738a4bd25a74bc1f220ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 13 Mar 2024 20:38:56 +0100 Subject: [PATCH 2/2] Fix unintended change --- ext/spl/spl_observer.stub.php | 5 ++++- ext/spl/spl_observer_arginfo.h | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ext/spl/spl_observer.stub.php b/ext/spl/spl_observer.stub.php index 13247eea1199d..24d4fd08aa746 100644 --- a/ext/spl/spl_observer.stub.php +++ b/ext/spl/spl_observer.stub.php @@ -157,6 +157,9 @@ public function current(): array {} /** @tentative-return-type */ public function next(): void {} - /** @tentative-return-type */ + /** + * @tentative-return-type + * @implementation-alias SplObjectStorage::__debugInfo + */ public function __debugInfo(): array {} } diff --git a/ext/spl/spl_observer_arginfo.h b/ext/spl/spl_observer_arginfo.h index 10852247938c0..913e481e57d52 100644 --- a/ext/spl/spl_observer_arginfo.h +++ b/ext/spl/spl_observer_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 2d075036abecd043dbf5f3a2ab0c57f2d49e42f0 */ + * Stub hash: 1fc23a91e7531eeb73729d4ad44addf0190c3a62 */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplObserver_update, 0, 1, IS_VOID, 0) ZEND_ARG_OBJ_INFO(0, subject, SplSubject, 0) @@ -166,7 +166,6 @@ ZEND_METHOD(MultipleIterator, valid); ZEND_METHOD(MultipleIterator, key); ZEND_METHOD(MultipleIterator, current); ZEND_METHOD(MultipleIterator, next); -ZEND_METHOD(MultipleIterator, __debugInfo); static const zend_function_entry class_SplObserver_methods[] = { ZEND_RAW_FENTRY("update", NULL, arginfo_class_SplObserver_update, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) @@ -221,7 +220,7 @@ static const zend_function_entry class_MultipleIterator_methods[] = { ZEND_ME(MultipleIterator, key, arginfo_class_MultipleIterator_key, ZEND_ACC_PUBLIC) ZEND_ME(MultipleIterator, current, arginfo_class_MultipleIterator_current, ZEND_ACC_PUBLIC) ZEND_ME(MultipleIterator, next, arginfo_class_MultipleIterator_next, ZEND_ACC_PUBLIC) - ZEND_ME(MultipleIterator, __debugInfo, arginfo_class_MultipleIterator___debugInfo, ZEND_ACC_PUBLIC) + ZEND_RAW_FENTRY("__debugInfo", zim_SplObjectStorage___debugInfo, arginfo_class_MultipleIterator___debugInfo, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_FE_END };