Annotation of embedaddon/php/Zend/tests/traits/property001.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Potentially conflicting properties should result in a strict notice. Property use is discorage for traits that are supposed to enable maintainable code reuse. Accessor methods are the language supported idiom for this.
3: --FILE--
4: <?php
5: error_reporting(E_ALL);
6:
7: trait THello1 {
8: private $foo;
9: }
10:
11: trait THello2 {
12: private $foo;
13: }
14:
15: echo "PRE-CLASS-GUARD-TraitsTest\n";
16: error_reporting(E_ALL & ~E_STRICT); // ensuring that it is only for E_STRICT
17:
18: class TraitsTest {
19: use THello1;
20: use THello2;
21: }
22:
23: error_reporting(E_ALL | E_STRICT);
24:
25: echo "PRE-CLASS-GUARD-TraitsTest2\n";
26:
27: class TraitsTest2 {
28: use THello1;
29: use THello2;
30: }
31:
32: var_dump(property_exists('TraitsTest', 'foo'));
33: var_dump(property_exists('TraitsTest2', 'foo'));
34: ?>
35: --EXPECTF--
36: PRE-CLASS-GUARD-TraitsTest
37: PRE-CLASS-GUARD-TraitsTest2
38:
39: Strict Standards: THello1 and THello2 define the same property ($foo) in the composition of TraitsTest2. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in %s on line %d
40: bool(true)
41: bool(true)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>