xref: /PHP-8.1/Zend/tests/traits/property007.phpt (revision ffc87174)
1--TEST--
2Introducing new private variables of the same name in a subclass is ok, and does not lead to any output. That is consistent with normal inheritance handling.
3--FILE--
4<?php
5
6class Base {
7  protected $hello;
8}
9
10trait THello1 {
11  protected $hello;
12}
13
14// Protected and public are handle more strict with a warning then what is
15// expected from normal inheritance since they can have easier colliding semantics
16echo "PRE-CLASS-GUARD\n";
17class SameNameInSubClassProducesNotice extends Base {
18    use THello1;
19}
20echo "POST-CLASS-GUARD\n";
21
22// now the same with a class that defines the property itself, too.
23
24class Notice extends Base {
25    use THello1;
26    protected $hello;
27}
28echo "POST-CLASS-GUARD2\n";
29?>
30--EXPECT--
31PRE-CLASS-GUARD
32POST-CLASS-GUARD
33POST-CLASS-GUARD2
34