xref: /PHP-5.5/Zend/tests/traits/property005.phpt (revision 525dd55e)
1--TEST--
2The 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.
3--FILE--
4<?php
5error_reporting(E_ALL | E_STRICT);
6
7class Base {
8  private $hello;
9}
10
11trait THello1 {
12  private $hello;
13}
14
15echo "PRE-CLASS-GUARD\n";
16class Notice extends Base {
17    use THello1;
18    private $hello;
19}
20echo "POST-CLASS-GUARD\n";
21
22// now we do the test for a fatal error
23
24class TraitsTest {
25	use THello1;
26    public $hello;
27}
28
29echo "POST-CLASS-GUARD2\n";
30
31$t = new TraitsTest;
32$t->hello = "foo";
33?>
34--EXPECTF--
35PRE-CLASS-GUARD
36
37Strict 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
38POST-CLASS-GUARD
39
40Fatal 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
41