bug60536_002.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 occures. (relevant with #60536)
  3. --FILE--
  4. <?php
  5. error_reporting(E_ALL | E_STRICT);
  6. class Base {
  7. private $hello;
  8. }
  9. trait THello1 {
  10. private $hello;
  11. }
  12. echo "PRE-CLASS-GUARD\n";
  13. class Notice extends Base {
  14. use THello1;
  15. private $hello;
  16. }
  17. echo "POST-CLASS-GUARD\n";
  18. // now we do the test for a fatal error
  19. class TraitsTest {
  20. use THello1;
  21. public $hello;
  22. }
  23. echo "POST-CLASS-GUARD2\n";
  24. $t = new TraitsTest;
  25. $t->hello = "foo";
  26. ?>
  27. --EXPECTF--
  28. PRE-CLASS-GUARD
  29. Strict Standards: Notice and THello1 define the same property ($hello) in the composition of Notice. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in %s on line %d
  30. POST-CLASS-GUARD
  31. 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