Voting

: min(one, two)?
(Example: nine)

The Note You're Voting On

kkuczok at gmail dot com
12 years ago
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] )

)

<< Back to user notes page

To Top