1--TEST-- 2ReflectionParameter::isDefaultValueConstant() && getDefaultValueConstantName() 3--FILE-- 4<?php 5 6define("CONST_TEST_1", "const1"); 7 8function ReflectionParameterTest($test1=array(), $test2 = CONST_TEST_1) { 9 echo $test; 10} 11$reflect = new ReflectionFunction('ReflectionParameterTest'); 12foreach($reflect->getParameters() as $param) { 13 if($param->getName() == 'test1') { 14 var_dump($param->isDefaultValueConstant()); 15 } 16 if($param->getName() == 'test2') { 17 var_dump($param->isDefaultValueConstant()); 18 } 19 if($param->isDefaultValueAvailable() && $param->isDefaultValueConstant()) { 20 var_dump($param->getDefaultValueConstantName()); 21 } 22} 23 24class Foo2 { 25 const bar = 'Foo2::bar'; 26} 27 28class Foo { 29 const bar = 'Foo::bar'; 30 31 public function baz($param1 = self::bar, $param2=Foo2::bar, $param3=CONST_TEST_1) { 32 } 33} 34 35$method = new ReflectionMethod('Foo', 'baz'); 36$params = $method->getParameters(); 37 38foreach ($params as $param) { 39 if ($param->isDefaultValueConstant()) { 40 var_dump($param->getDefaultValueConstantName()); 41 } 42} 43?> 44==DONE== 45--EXPECT-- 46bool(false) 47bool(true) 48string(12) "CONST_TEST_1" 49string(9) "self::bar" 50string(9) "Foo2::bar" 51string(12) "CONST_TEST_1" 52==DONE== 53