Skip to content

ext/gmp: Make GMP class final #15121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion ext/gmp/gmp.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
*/
const GMP_NATIVE_ENDIAN = UNKNOWN;

class GMP
final class GMP
{
public function __construct(int|string $num = 0, int $base = 0) {}

Expand Down
3 changes: 2 additions & 1 deletion ext/gmp/gmp_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions ext/gmp/tests/final.phpt
Original file line number Diff line number Diff line change
@@ -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
Loading