flattening001.phpt 566 B

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