Annotation of embedaddon/php/Zend/tests/lsb_001.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: ZE2 Late Static Binding in a static 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 static function testStaticVar() {
! 15: return static::$staticVar;
! 16: }
! 17:
! 18: public static function testClassConst() {
! 19: return static::CLASS_CONST;
! 20: }
! 21:
! 22: public static 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: echo TestClass::testStaticVar() . "\n";
! 39: echo TestClass::testClassConst() . "\n";
! 40: echo TestClass::testStaticFunction() . "\n";
! 41:
! 42: echo ChildClass1::testStaticVar() . "\n";
! 43: echo ChildClass1::testClassConst() . "\n";
! 44: echo ChildClass1::testStaticFunction() . "\n";
! 45:
! 46: echo ChildClass2::testStaticVar() . "\n";
! 47: echo ChildClass2::testClassConst() . "\n";
! 48: echo ChildClass2::testStaticFunction() . "\n";
! 49: ?>
! 50: ==DONE==
! 51: --EXPECTF--
! 52: TestClassStatic
! 53: TestClassConst
! 54: TestClassFunction
! 55: ChildClassStatic
! 56: ChildClassConst
! 57: ChildClassFunction
! 58: TestClassStatic
! 59: TestClassConst
! 60: TestClassFunction
! 61: ==DONE==
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>