xref: /PHP-7.2/Zend/tests/traits/property006.phpt (revision 17ccbeec)
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
35POST-CLASS-GUARD2
36