ext/gmp: Make GMP class final (#15121)

* ext/gmp: Make GMP class final

RFC: https://wiki.php.net/rfc/gmp-final

* Update UPGRADING

Co-authored-by: Peter Kokot <peterkokot@gmail.com>

---------

Co-authored-by: Peter Kokot <peterkokot@gmail.com>
This commit is contained in:
Gina Peter Banyard 2024-07-28 13:03:26 +01:00 committed by GitHub
parent 9d7e6090df
commit a50adda19e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 22 additions and 2 deletions

3
NEWS
View File

@ -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)

View File

@ -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:

View File

@ -57,7 +57,7 @@ const GMP_BIG_ENDIAN = UNKNOWN;
*/
const GMP_NATIVE_ENDIAN = UNKNOWN;
class GMP
final class GMP
{
public function __construct(int|string $num = 0, int $base = 0) {}

3
ext/gmp/gmp_arginfo.h generated
View File

@ -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;
}

12
ext/gmp/tests/final.phpt Normal file
View File

@ -0,0 +1,12 @@
--TEST--
Cannot extend GMP class
--EXTENSIONS--
gmp
--FILE--
<?php
class T extends GMP {}
?>
--EXPECTF--
Fatal error: Class T cannot extend final class GMP in %s on line %d