summaryrefslogtreecommitdiff
path: root/Zend/tests/lsb_002.phpt
blob: 4fca6ddd72bdc2d3fe993d2a7dc43001795ea5df (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
62
63
64
65
66
--TEST--
ZE2 Late Static Binding in an instance function
--FILE--
<?php

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

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

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

	public 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 {}

$testClass = new TestClass();
$childClass1 = new ChildClass1();
$childClass2 = new ChildClass2();


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==