mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00

The deprecation message was originally introduced in 3e6b447
(#6494).
I first encountered this notice when testing the MongoDB extension
with PHP 8.1, which produced many duplicate messages that provided
no detail about the particular class that needed to be fixed.
Closes GH-7346.
26 lines
685 B
PHP
26 lines
685 B
PHP
--TEST--
|
|
Enum must not implement Serializable indirectly
|
|
--FILE--
|
|
<?php
|
|
|
|
interface MySerializable extends Serializable {}
|
|
|
|
enum Foo implements MySerializable {
|
|
case Bar;
|
|
|
|
public function serialize() {
|
|
return serialize('Hello');
|
|
}
|
|
|
|
public function unserialize($data) {
|
|
return unserialize($data);
|
|
}
|
|
}
|
|
|
|
var_dump(unserialize(serialize(Foo::Bar)));
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
|
|
|
|
Fatal error: Enums may not implement the Serializable interface in %s on line %d
|