Fixed PHP bug #50798 (Unable to retrieve default value of argument of internal method with reflection) and added example to ReflectionParameter::getDefaultValue().

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@293765 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Daniel Egeberg 2010-01-20 11:41:23 +00:00
parent a19eb7ea49
commit 68c5267334

View file

@ -14,11 +14,10 @@
<void />
</methodsynopsis>
<para>
Gets the parameters default value.
Gets the default value of the parameter for a user-defined function or method.
If the parameter is not optional a <classname>ReflectionException</classname>
will be thrown.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -32,6 +31,55 @@
The parameters default value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Getting </title>
<programlisting role="php">
<![CDATA[
<?php
function foo($test, $bar = 'baz')
{
echo $test . $bar;
}
$function = new ReflectionFunction('foo');
foreach ($function->getParameters() as $param) {
echo 'Name: ' . $param->getName() . PHP_EOL;
if ($param->isOptional()) {
echo 'Default value: ' . $param->getDefaultValue() . PHP_EOL;
}
echo PHP_EOL;
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Name: test
Name: bar
Default value: baz
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
Due to implementation details, it is not possible to get the default value
of built-in functions or methods of built-in classes. Trying to do this will
result a <classname>ReflectionException</classname> being thrown.
</para>
</note>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;