1--TEST-- 2ZE2 Late Static Binding in an instance function 3--FILE-- 4<?php 5 6class 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 27class 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 36class ChildClass2 extends TestClass {} 37 38$testClass = new TestClass(); 39$childClass1 = new ChildClass1(); 40$childClass2 = new ChildClass2(); 41 42 43echo $testClass->testStaticVar() . "\n"; 44echo $testClass->testClassConst() . "\n"; 45echo $testClass->testStaticFunction() . "\n"; 46 47echo $childClass1->testStaticVar() . "\n"; 48echo $childClass1->testClassConst() . "\n"; 49echo $childClass1->testStaticFunction() . "\n"; 50 51echo $childClass2->testStaticVar() . "\n"; 52echo $childClass2->testClassConst() . "\n"; 53echo $childClass2->testStaticFunction() . "\n"; 54?> 55--EXPECT-- 56TestClassStatic 57TestClassConst 58TestClassFunction 59ChildClassStatic 60ChildClassConst 61ChildClassFunction 62TestClassStatic 63TestClassConst 64TestClassFunction 65