diff options
author | Dmitry Stogov <dmitry@php.net> | 2007-09-29 07:28:34 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2007-09-29 07:28:34 +0000 |
commit | 166266df68db50c4d1119f2be265972c8d77f1af (patch) | |
tree | db37ce528d82613d84737d6e30cb8fe8f14c9b78 /Zend/tests/lsb_001.phpt | |
parent | e9dd6fab9194b3ae717b79322853dfa6fb64fb28 (diff) | |
download | php-git-166266df68db50c4d1119f2be265972c8d77f1af.tar.gz |
Added support for Late Static Binding. (Dmitry, Etienne Kneuss)
Diffstat (limited to 'Zend/tests/lsb_001.phpt')
-rw-r--r-- | Zend/tests/lsb_001.phpt | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Zend/tests/lsb_001.phpt b/Zend/tests/lsb_001.phpt new file mode 100644 index 0000000000..20a2fd83bb --- /dev/null +++ b/Zend/tests/lsb_001.phpt @@ -0,0 +1,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== |