Annotation of embedaddon/php/Zend/tests/lsb_002.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: ZE2 Late Static Binding in an instance function
! 3: --FILE--
! 4: <?php
! 5:
! 6: class TestClass {
! 7: protected static $staticVar = 'TestClassStatic';
! 8: const CLASS_CONST = 'TestClassConst';
! 9:
! 10: protected static function staticFunction() {
! 11: return 'TestClassFunction';
! 12: }
! 13:
! 14: public function testStaticVar() {
! 15: return static::$staticVar;
! 16: }
! 17:
! 18: public function testClassConst() {
! 19: return static::CLASS_CONST;
! 20: }
! 21:
! 22: public function testStaticFunction() {
! 23: return static::staticFunction();
! 24: }
! 25: }
! 26:
! 27: class ChildClass1 extends TestClass {
! 28: protected static $staticVar = 'ChildClassStatic';
! 29: const CLASS_CONST = 'ChildClassConst';
! 30:
! 31: protected static function staticFunction() {
! 32: return 'ChildClassFunction';
! 33: }
! 34: }
! 35:
! 36: class ChildClass2 extends TestClass {}
! 37:
! 38: $testClass = new TestClass();
! 39: $childClass1 = new ChildClass1();
! 40: $childClass2 = new ChildClass2();
! 41:
! 42:
! 43: echo $testClass->testStaticVar() . "\n";
! 44: echo $testClass->testClassConst() . "\n";
! 45: echo $testClass->testStaticFunction() . "\n";
! 46:
! 47: echo $childClass1->testStaticVar() . "\n";
! 48: echo $childClass1->testClassConst() . "\n";
! 49: echo $childClass1->testStaticFunction() . "\n";
! 50:
! 51: echo $childClass2->testStaticVar() . "\n";
! 52: echo $childClass2->testClassConst() . "\n";
! 53: echo $childClass2->testStaticFunction() . "\n";
! 54: ?>
! 55: ==DONE==
! 56: --EXPECTF--
! 57: TestClassStatic
! 58: TestClassConst
! 59: TestClassFunction
! 60: ChildClassStatic
! 61: ChildClassConst
! 62: ChildClassFunction
! 63: TestClassStatic
! 64: TestClassConst
! 65: TestClassFunction
! 66: ==DONE==
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>