xref: /PHP-8.2/Zend/tests/lsb_019.phpt (revision f8d79582)
1--TEST--
2ZE2 Late Static Binding properties and methods declared as protected and overridden as public.
3--FILE--
4<?php
5class TestClass {
6    protected static $staticVar;
7
8    protected static function staticFunction() {
9        return 'TestClassFunction';
10    }
11
12    public static function testStaticVar() {
13        TestClass::$staticVar = 'TestClassStatic';
14        ChildClass1::$staticVar = 'ChildClassStatic';
15        return static::$staticVar;
16    }
17
18    public static function testStaticFunction() {
19        return static::staticFunction();
20    }
21}
22
23class ChildClass1 extends TestClass {
24    public static $staticVar;
25
26    public static function staticFunction() {
27        return 'ChildClassFunction';
28    }
29}
30
31class ChildClass2 extends TestClass {}
32
33echo TestClass::testStaticVar() . "\n";
34echo TestClass::testStaticFunction() . "\n";
35
36echo ChildClass1::testStaticVar() . "\n";
37echo ChildClass1::testStaticFunction() . "\n";
38
39echo ChildClass2::testStaticVar() . "\n";
40echo ChildClass2::testStaticFunction() . "\n";
41?>
42--EXPECT--
43TestClassStatic
44TestClassFunction
45ChildClassStatic
46ChildClassFunction
47TestClassStatic
48TestClassFunction
49