1--TEST-- 2Testing magic method on trait 3--FILE-- 4<?php 5 6trait foo { 7 public function __toString() { 8 return '123'; 9 } 10 11 public function __get($x) { 12 var_dump($x); 13 } 14 15 public function __set($attr, $val) { 16 var_dump($attr .'==='. $val); 17 } 18 19 public function __clone() { 20 var_dump(__FUNCTION__); 21 } 22} 23 24class bar { 25 use foo; 26} 27 28$o = new bar; 29echo $o, PHP_EOL; 30$o->xyz; 31$o->xyz = 2; 32clone $o; 33 34?> 35--EXPECT-- 36123 37string(3) "xyz" 38string(7) "xyz===2" 39string(7) "__clone" 40