1--TEST-- 2Methods using object properties 3--FILE-- 4<?php 5error_reporting(E_ALL); 6 7trait T1 { 8 public function getText() { 9 return $this->text; 10 } 11} 12 13trait T2 { 14 public function setTextT2($val) { 15 $this->text = $val; 16 } 17} 18 19class TraitsTest { 20 use T1; 21 use T2; 22 private $text = 'test'; 23 public function setText($val) { 24 $this->text = $val; 25 } 26} 27 28$o = new TraitsTest(); 29var_dump($o->getText()); 30 31$o->setText('foo'); 32 33var_dump($o->getText()); 34 35$o->setText('bar'); 36 37var_dump($o->getText()); 38?> 39--EXPECTF-- 40string(4) "test" 41string(3) "foo" 42string(3) "bar"