svn: /phpdoc/en/trunk/reference/reflection/reflectionparameter/ getdefaultvalue.xml

From: Date: Wed, 20 Jan 2010 11:41:23 +0000
Subject: svn: /phpdoc/en/trunk/reference/reflection/reflectionparameter/ getdefaultvalue.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-5900@lists.php.net to get a copy of this message
degeberg Wed, 20 Jan 2010 11:41:23 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=293765 Log: Fixed PHP bug #50798 (Unable to retrieve default value of argument of internal method with reflection) and added example to ReflectionParameter::getDefaultValue(). Bug: http://bugs.php.net/50798 (Open) Unable to retrieve default value of argument of internal method with reflection Changed paths: U phpdoc/en/trunk/reference/reflection/reflectionparameter/getdefaultvalue.xml Modified: phpdoc/en/trunk/reference/reflection/reflectionparameter/getdefaultvalue.xml =================================================================== --- phpdoc/en/trunk/reference/reflection/reflectionparameter/getdefaultvalue.xml 2010-01-20 10:58:29 UTC (rev 293764) +++ phpdoc/en/trunk/reference/reflection/reflectionparameter/getdefaultvalue.xml 2010-01-20 11:41:23 UTC (rev 293765) @@ -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,7 +31,56 @@ 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; <para>

« previous php.doc.cvs (#5900) next »