summaryrefslogtreecommitdiff
path: root/Zend/tests/lsb_001.phpt
blob: 20a2fd83bbc2588a1e499337e98a139b1cb7eb32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
--TEST--
ZE2 Late Static Binding in a static function
--FILE--
<?php

class TestClass {
	protected static $staticVar = 'TestClassStatic';
	const CLASS_CONST = 'TestClassConst';

	protected static function staticFunction() {
		return 'TestClassFunction';
	}
	
	public static function testStaticVar() {
		return static::$staticVar;
	}

	public static function testClassConst() {
		return static::CLASS_CONST;
	}

	public static function testStaticFunction() {
		return static::staticFunction();
	}
}

class ChildClass1 extends TestClass {
	protected static $staticVar = 'ChildClassStatic';
	const CLASS_CONST = 'ChildClassConst';

	protected static function staticFunction() {
		return 'ChildClassFunction';
	}
}

class ChildClass2 extends TestClass {}

echo TestClass::testStaticVar() . "\n";
echo TestClass::testClassConst() . "\n";
echo TestClass::testStaticFunction() . "\n";

echo ChildClass1::testStaticVar() . "\n";
echo ChildClass1::testClassConst() . "\n";
echo ChildClass1::testStaticFunction() . "\n";

echo ChildClass2::testStaticVar() . "\n";
echo ChildClass2::testClassConst() . "\n";
echo ChildClass2::testStaticFunction() . "\n";
?>
==DONE==
--EXPECTF--
TestClassStatic
TestClassConst
TestClassFunction
ChildClassStatic
ChildClassConst
ChildClassFunction
TestClassStatic
TestClassConst
TestClassFunction
==DONE==