mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01: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.
29 lines
638 B
PHP
29 lines
638 B
PHP
--TEST--
|
|
Testing to implement Serializable interface by traits
|
|
--FILE--
|
|
<?php
|
|
|
|
trait foo {
|
|
public function serialize() {
|
|
return 'foobar';
|
|
}
|
|
public function unserialize($x) {
|
|
var_dump($x);
|
|
}
|
|
}
|
|
|
|
class bar implements Serializable {
|
|
use foo;
|
|
}
|
|
|
|
var_dump($o = serialize(new bar));
|
|
var_dump(unserialize($o));
|
|
|
|
?>
|
|
--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
|
|
string(20) "C:3:"bar":6:{foobar}"
|
|
string(6) "foobar"
|
|
object(bar)#%d (0) {
|
|
}
|