1--TEST-- 2Testing to implement Serializable interface by traits 3--FILE-- 4<?php 5 6trait foo { 7 public function serialize() { 8 return 'foobar'; 9 } 10 public function unserialize($x) { 11 var_dump($x); 12 } 13} 14 15class bar implements Serializable { 16 use foo; 17} 18 19var_dump($o = serialize(new bar)); 20var_dump(unserialize($o)); 21 22?> 23--EXPECTF-- 24Deprecated: %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 25string(20) "C:3:"bar":6:{foobar}" 26string(6) "foobar" 27object(bar)#%d (0) { 28} 29