1--TEST-- 2ReflectionFunction basic tests 3--INI-- 4opcache.save_comments=1 5opcache.load_comments=1 6--FILE-- 7<?php 8 9/** 10hoho 11*/ 12function test ($a, $b = 1, $c = "") { 13 static $var = 1; 14} 15 16$func = new ReflectionFunction("test"); 17 18var_dump($func->export("test")); 19echo "--getName--\n"; 20var_dump($func->getName()); 21echo "--isInternal--\n"; 22var_dump($func->isInternal()); 23echo "--isUserDefined--\n"; 24var_dump($func->isUserDefined()); 25echo "--getFilename--\n"; 26var_dump($func->getFilename()); 27echo "--getStartline--\n"; 28var_dump($func->getStartline()); 29echo "--getEndline--\n"; 30var_dump($func->getEndline()); 31echo "--getDocComment--\n"; 32var_dump($func->getDocComment()); 33echo "--getStaticVariables--\n"; 34var_dump($func->getStaticVariables()); 35echo "--invoke--\n"; 36var_dump($func->invoke(array(1,2,3))); 37echo "--invokeArgs--\n"; 38var_dump($func->invokeArgs(array(1,2,3))); 39echo "--returnsReference--\n"; 40var_dump($func->returnsReference()); 41echo "--getParameters--\n"; 42var_dump($func->getParameters()); 43echo "--getNumberOfParameters--\n"; 44var_dump($func->getNumberOfParameters()); 45echo "--getNumberOfRequiredParameters--\n"; 46var_dump($func->getNumberOfRequiredParameters()); 47 48echo "Done\n"; 49 50?> 51--EXPECTF-- 52/** 53hoho 54*/ 55Function [ <user> function test ] { 56 @@ %s009.php 6 - 8 57 58 - Parameters [3] { 59 Parameter #0 [ <required> $a ] 60 Parameter #1 [ <optional> $b = 1 ] 61 Parameter #2 [ <optional> $c = '' ] 62 } 63} 64 65NULL 66--getName-- 67string(4) "test" 68--isInternal-- 69bool(false) 70--isUserDefined-- 71bool(true) 72--getFilename-- 73string(%d) "%s009.php" 74--getStartline-- 75int(6) 76--getEndline-- 77int(8) 78--getDocComment-- 79string(11) "/** 80hoho 81*/" 82--getStaticVariables-- 83array(1) { 84 ["var"]=> 85 int(1) 86} 87--invoke-- 88NULL 89--invokeArgs-- 90NULL 91--returnsReference-- 92bool(false) 93--getParameters-- 94array(3) { 95 [0]=> 96 &object(ReflectionParameter)#2 (1) { 97 ["name"]=> 98 string(1) "a" 99 } 100 [1]=> 101 &object(ReflectionParameter)#3 (1) { 102 ["name"]=> 103 string(1) "b" 104 } 105 [2]=> 106 &object(ReflectionParameter)#4 (1) { 107 ["name"]=> 108 string(1) "c" 109 } 110} 111--getNumberOfParameters-- 112int(3) 113--getNumberOfRequiredParameters-- 114int(1) 115Done 116