1
0
mirror of https://github.com/php/php-src.git synced 2026-04-17 13:01:02 +02:00
Files
archived-php-src/Zend/tests/traits/interface_003.phpt
Nikita Popov 3e6b447979 Partially deprecate Serializable
If Serializable is implemented, require that __serialize() and
__unserialize() are implemented as well, else issue a deprecation
warning.

Also deprecate use of PDO::FETCH_SERIALIZE.

RFC: https://wiki.php.net/rfc/phase_out_serializable

Closes GH-6494.
2021-04-28 16:55:14 +02:00

29 lines
617 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: The Serializable interface 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) {
}