diff --git a/NEWS b/NEWS index b9753c06aa14b..147d6ce70f504 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,9 @@ PHP NEWS . /dev/poll events.mechanism for Solaris/Illumos setting had been retired. (David Carlier) +- GMP: + . The GMP class is now final and cannot be extended anymore. + - Intl: . Added SpoofChecker::setAllowedChars to set unicode chars ranges. (David Carlier) diff --git a/UPGRADING b/UPGRADING index 4974182f4d4a7..0fe03244ab187 100644 --- a/UPGRADING +++ b/UPGRADING @@ -48,6 +48,10 @@ PHP 8.4 UPGRADE NOTES object. This is no longer possible, and cloning a DOMXPath object now throws an error. +- GMP: + . The GMP class is now final and cannot be extended anymore. + RFC: https://wiki.php.net/rfc/gmp-final + - Intl: . resourcebundle_get(), ResourceBundle::get(), and accessing offsets on a ResourceBundle object now throw: diff --git a/ext/gmp/gmp.stub.php b/ext/gmp/gmp.stub.php index ff5b5afb4055b..75812c62c5ca3 100644 --- a/ext/gmp/gmp.stub.php +++ b/ext/gmp/gmp.stub.php @@ -57,7 +57,7 @@ */ const GMP_NATIVE_ENDIAN = UNKNOWN; -class GMP +final class GMP { public function __construct(int|string $num = 0, int $base = 0) {} diff --git a/ext/gmp/gmp_arginfo.h b/ext/gmp/gmp_arginfo.h index 8126fa6686731..43d6944036888 100644 --- a/ext/gmp/gmp_arginfo.h +++ b/ext/gmp/gmp_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: d52f82c7084a8122fe07c91eb6d4ab6030daa27d */ + * Stub hash: 3aabd5a5d2db0df15b249a425465ae718c13ab6b */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gmp_init, 0, 1, GMP, 0) ZEND_ARG_TYPE_MASK(0, num, MAY_BE_LONG|MAY_BE_STRING, NULL) @@ -334,6 +334,7 @@ static zend_class_entry *register_class_GMP(void) INIT_CLASS_ENTRY(ce, "GMP", class_GMP_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; return class_entry; } diff --git a/ext/gmp/tests/final.phpt b/ext/gmp/tests/final.phpt new file mode 100644 index 0000000000000..1bc485ac6e168 --- /dev/null +++ b/ext/gmp/tests/final.phpt @@ -0,0 +1,12 @@ +--TEST-- +Cannot extend GMP class +--EXTENSIONS-- +gmp +--FILE-- + +--EXPECTF-- +Fatal error: Class T cannot extend final class GMP in %s on line %d