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