From 75582d4e91572242e4a63c6e40c9f16ed5d3040b Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sat, 27 Jul 2024 12:00:56 +0100 Subject: [PATCH 1/2] ext/gmp: Make GMP class final RFC: https://wiki.php.net/rfc/gmp-final --- NEWS | 3 +++ UPGRADING | 3 +++ ext/gmp/gmp.stub.php | 2 +- ext/gmp/gmp_arginfo.h | 3 ++- ext/gmp/tests/final.phpt | 12 ++++++++++++ 5 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 ext/gmp/tests/final.phpt 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..dfb7b24bea9c6 100644 --- a/UPGRADING +++ b/UPGRADING @@ -48,6 +48,9 @@ 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. + - 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 From 693a3b125e8f3757766cf732873eeeaf6bbe51dc Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 28 Jul 2024 13:03:08 +0100 Subject: [PATCH 2/2] Update UPGRADING Co-authored-by: Peter Kokot --- UPGRADING | 1 + 1 file changed, 1 insertion(+) diff --git a/UPGRADING b/UPGRADING index dfb7b24bea9c6..0fe03244ab187 100644 --- a/UPGRADING +++ b/UPGRADING @@ -50,6 +50,7 @@ PHP 8.4 UPGRADE NOTES - 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