xref: /PHP-8.1/Zend/tests/traits/property003.phpt (revision f8d79582)
1--TEST--
2Conflicting properties with different visibility modifiers should result in a fatal error, since this indicates that the code is incompatible.
3--FILE--
4<?php
5
6trait THello1 {
7  public $hello;
8}
9
10trait THello2 {
11  private $hello;
12}
13
14echo "PRE-CLASS-GUARD\n";
15
16class TraitsTest {
17    use THello1;
18    use THello2;
19}
20
21echo "POST-CLASS-GUARD\n";
22
23$t = new TraitsTest;
24$t->hello = "foo";
25?>
26--EXPECTF--
27PRE-CLASS-GUARD
28
29Fatal error: THello1 and THello2 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
30