Annotation of embedaddon/php/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: ReflectionParameter::isDefaultValueConstant() && getDefaultValueConstantName()
! 3: --FILE--
! 4: <?php
! 5:
! 6: define("CONST_TEST_1", "const1");
! 7:
! 8: function ReflectionParameterTest($test1=array(), $test2 = CONST_TEST_1) {
! 9: echo $test;
! 10: }
! 11: $reflect = new ReflectionFunction('ReflectionParameterTest');
! 12: foreach($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:
! 24: class Foo2 {
! 25: const bar = 'Foo2::bar';
! 26: }
! 27:
! 28: class 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:
! 38: foreach ($params as $param) {
! 39: if ($param->isDefaultValueConstant()) {
! 40: var_dump($param->getDefaultValueConstantName());
! 41: }
! 42: }
! 43: ?>
! 44: ==DONE==
! 45: --EXPECT--
! 46: bool(false)
! 47: bool(true)
! 48: string(12) "CONST_TEST_1"
! 49: string(9) "self::bar"
! 50: string(9) "Foo2::bar"
! 51: string(12) "CONST_TEST_1"
! 52: ==DONE==
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>