xref: /php-src/Zend/tests/gh10935.phpt (revision 9a250cc9)
1--TEST--
2GH-1093: Add separate static property through trait if parent already declares it
3--FILE--
4<?php
5trait Foo {
6    static $test;
7
8    public static function getFooSelf() {
9        return self::$test;
10    }
11
12    public static function getFooStatic() {
13        return static::$test;
14    }
15}
16trait Bar {
17    public static function getBarSelf() {
18        return self::$test;
19    }
20
21    public static function getBarStatic() {
22        return static::$test;
23    }
24}
25
26class A {
27    use Foo;
28    use Bar;
29
30    public static function getASelf() {
31        return self::$test;
32    }
33
34    public static function getAStatic() {
35        return static::$test;
36    }
37}
38
39class B extends A {
40    use Foo;
41
42    public static function getBSelf() {
43        return self::$test;
44    }
45
46    public static function getBStatic() {
47        return static::$test;
48    }
49}
50
51A::$test = 'A';
52B::$test = 'B';
53
54echo 'A::$test: ' . A::$test . "\n";
55echo 'A::getASelf(): ' . A::getASelf() . "\n";
56echo 'A::getAStatic(): ' . A::getAStatic() . "\n";
57echo 'A::getFooSelf(): ' . A::getFooSelf() . "\n";
58echo 'A::getFooStatic(): ' . A::getFooStatic() . "\n";
59echo 'B::$test: ' . B::$test . "\n";
60echo 'B::getASelf(): ' . B::getASelf() . "\n";
61echo 'B::getAStatic(): ' . B::getAStatic() . "\n";
62echo 'B::getBSelf(): ' . B::getBSelf() . "\n";
63echo 'B::getBStatic(): ' . B::getBStatic() . "\n";
64echo 'B::getFooSelf(): ' . B::getFooSelf() . "\n";
65echo 'B::getFooStatic(): ' . B::getFooStatic() . "\n";
66echo 'B::getBarSelf(): ' . B::getBarSelf() . "\n";
67echo 'B::getBarStatic(): ' . B::getBarStatic() . "\n";
68?>
69--EXPECT--
70A::$test: A
71A::getASelf(): A
72A::getAStatic(): A
73A::getFooSelf(): A
74A::getFooStatic(): A
75B::$test: B
76B::getASelf(): A
77B::getAStatic(): B
78B::getBSelf(): B
79B::getBStatic(): B
80B::getFooSelf(): B
81B::getFooStatic(): B
82B::getBarSelf(): A
83B::getBarStatic(): B
84