note 112248 added to function.get-defined-functions

From: Date: Wed, 22 May 2013 20:14:15 +0000
Subject: note 112248 added to function.get-defined-functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-194880@lists.php.net to get a copy of this message
You can list all arguments using ReflectionFunction class. It's not necessary to parse selected files/files as suggested by Nguyet.Duc. http://php.net/manual/pl/class.reflectionfunction.php Example: <?php function foo(&$bar, $big, $small = 1) {} function bar($foo) {} function noparams() {} function byrefandopt(&$the = 'one') {} $functions = get_defined_functions(); $functions_list = array(); foreach ($functions['user'] as $func) { $f = new ReflectionFunction($func); $args = array(); foreach ($f->getParameters() as $param) { $tmparg = ''; if ($param->isPassedByReference()) $tmparg = '&'; if ($param->isOptional()) { $tmparg = '[' . $tmparg . '$' . $param->getName() . ' = ' . $param->getDefaultValue() . ']'; } else { $tmparg.= '&' . $param->getName(); } $args[] = $tmparg; unset ($tmparg); } $functions_list[] = 'function ' . $func . ' ( ' . implode(', ', $args) . ' )' . PHP_EOL; } print_r($functions_list); ?> Output: Array ( [0] => function foo ( &&bar, &big, [$small = 1] ) [1] => function bar ( &foo ) [2] => function noparams ( ) [3] => function byrefandopt ( [&$the = one] ) ) ---- Server IP: 46.17.113.3 Probable Submitter: 83.26.104.112 ---- Manual Page -- http://php.net/manual/en/function.get-defined-functions.php Edit -- https://master.php.net/note/edit/112248 Del: integrated -- https://master.php.net/note/delete/112248/integrated Del: useless -- https://master.php.net/note/delete/112248/useless Del: bad code -- https://master.php.net/note/delete/112248/bad+code Del: spam -- https://master.php.net/note/delete/112248/spam Del: non-english -- https://master.php.net/note/delete/112248/non-english Del: in docs -- https://master.php.net/note/delete/112248/in+docs Del: other reasons-- https://master.php.net/note/delete/112248 Reject -- https://master.php.net/note/reject/112248 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194880) next »