bug60536_002.phpt 833 B

12345678910111213141516171819202122232425262728293031323334353637
  1. --TEST--
  2. The same rules are applied for properties that are defined in the class hierarchy. Thus, if the properties are compatible, a notice is issued, if not a fatal error occurs. (relevant with #60536)
  3. --FILE--
  4. <?php
  5. class Base {
  6. private $hello;
  7. }
  8. trait THello1 {
  9. private $hello;
  10. }
  11. echo "PRE-CLASS-GUARD\n";
  12. class Notice extends Base {
  13. use THello1;
  14. private $hello;
  15. }
  16. echo "POST-CLASS-GUARD\n";
  17. // now we do the test for a fatal error
  18. class TraitsTest {
  19. use THello1;
  20. public $hello;
  21. }
  22. echo "POST-CLASS-GUARD2\n";
  23. $t = new TraitsTest;
  24. $t->hello = "foo";
  25. ?>
  26. --EXPECTF--
  27. PRE-CLASS-GUARD
  28. POST-CLASS-GUARD
  29. Fatal error: TraitsTest and THello1 define the same property ($hello) in the composition of TraitsTest. However, the definition differs and is considered incompatible. Class was composed in %s on line %d