Skip to content

Commit 60bbe0b

Browse files
LeonMelisLolGleb
authored andcommitted
Remove Serializable interface from GMP class
Trying to use `$gmp->serialize()` or `$gmp->unserialize()` as defined in the stubs will result in `Error: Call to undefined method GMP::serialize()` PHP does not provide an object-oriented interface to manipulate GMP objects, only a procedural GMP API. See: https://www.php.net/manual/en/class.gmp.php > _"No object-oriented interface is provided to manipulate GMP objects. Please use the procedural GMP API."_ This can be confirmed in the PHP source code, the GMP class does not implement the `Serializable` interface, see: https://github.com/php/php-src/blob/master/ext/gmp/gmp.c#L584 If `Serializable` interface was implemented in the PHP source code, then we would have expected to see `register_class_GMP(zend_ce_serializable)`.
1 parent d314372 commit 60bbe0b

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

gmp/gmp.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -798,32 +798,32 @@ function gmp_perfect_power(GMP|string|int $num): bool {}
798798

799799
define('GMP_MPIR_VERSION', '3.0.0');
800800

801-
final class GMP implements Serializable
801+
final class GMP
802802
{
803803
/**
804804
* @since 8.2
805805
*/
806806
public function __construct(int|string $num = 0, int $base = 0) {}
807807

808808
/**
809-
* String representation of object
810-
* @link https://php.net/manual/en/serializable.serialize.php
811-
* @return string the string representation of the object or null
809+
* Get array representation of object
810+
* @link https://www.php.net/manual/en/language.oop5.magic.php#object.serialize
811+
* @return string[] <p>
812+
* The array representation of the GMP object. For GMP this is expected to be a
813+
* single-element list (zero-indexed) containing the string representation of the
814+
* GMP number
815+
* </p>
812816
*/
813-
public function serialize() {}
814-
815817
public function __serialize(): array {}
816818

817819
/**
818-
* Constructs the object
819-
* @link https://php.net/manual/en/serializable.unserialize.php
820-
* @param string $data <p>
821-
* The string representation of the object.
820+
* Reconstructs the GMP object from array representation
821+
* @link https://www.php.net/manual/en/language.oop5.magic.php#object.serialize
822+
* @param string[] $data <p>
823+
* The array representation of the GMP object.
822824
* </p>
823825
* @return void
824826
*/
825-
public function unserialize($data) {}
826-
827827
public function __unserialize(array $data): void {}
828828
}
829829
// End of gmp v.

0 commit comments

Comments
 (0)