xref: /PHP-5.4/Zend/tests/traits/property006.phpt (revision 3dc9f0ab)
1--TEST--
2Introducing new private variables of the same name in a subclass is ok, and does not lead to any output. That is consitent with normal inheritance handling.
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
15// Now we use the trait, which happens to introduce another private variable
16// but they are distinct, and not related to each other, so no warning.
17echo "PRE-CLASS-GUARD\n";
18class SameNameInSubClassNoNotice extends Base {
19    use THello1;
20}
21echo "POST-CLASS-GUARD\n";
22
23// now the same with a class that defines the property itself,
24// that should give the expected strict warning.
25
26class Notice extends Base {
27    use THello1;
28    private $hello;
29}
30echo "POST-CLASS-GUARD2\n";
31?>
32--EXPECTF--
33PRE-CLASS-GUARD
34POST-CLASS-GUARD
35
36Strict 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
37POST-CLASS-GUARD2
38