svn: /phpdoc/en/trunk/reference/reflection/reflectionfunction/ construct.xml export.xml invoke.xml invokeargs.xml tostring.xml

From: Date: Wed, 20 Oct 2010 02:48:22 +0000
Subject: svn: /phpdoc/en/trunk/reference/reflection/reflectionfunction/ construct.xml export.xml invoke.xml invokeargs.xml tostring.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-7250@lists.php.net to get a copy of this message
kalle Wed, 20 Oct 2010 02:48:22 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=304525 Log: Properly documented the ReflectionFunction class, fixes #52158 (invokeArgs with args should be pass ref cause ReflectionException) Bug: http://bugs.php.net/52158 (Open) invokeArgs with args should be pass ref cause ReflectionException Changed paths: U phpdoc/en/trunk/reference/reflection/reflectionfunction/construct.xml U phpdoc/en/trunk/reference/reflection/reflectionfunction/export.xml U phpdoc/en/trunk/reference/reflection/reflectionfunction/invoke.xml U phpdoc/en/trunk/reference/reflection/reflectionfunction/invokeargs.xml U phpdoc/en/trunk/reference/reflection/reflectionfunction/tostring.xml Modified: phpdoc/en/trunk/reference/reflection/reflectionfunction/construct.xml =================================================================== --- phpdoc/en/trunk/reference/reflection/reflectionfunction/construct.xml 2010-10-20 02:16:34 UTC (rev 304524) +++ phpdoc/en/trunk/reference/reflection/reflectionfunction/construct.xml 2010-10-20 02:48:22 UTC (rev 304525) @@ -64,7 +64,7 @@ <row> <entry>5.3.0</entry> <entry> - <parameter>name</parameter> now allows <link linkend="functions.anonymous">closures</link>. + <parameter>name</parameter> can now be a <link linkend="functions.anonymous">closure</link>. </entry> </row> </tbody> Modified: phpdoc/en/trunk/reference/reflection/reflectionfunction/export.xml =================================================================== --- phpdoc/en/trunk/reference/reflection/reflectionfunction/export.xml 2010-10-20 02:16:34 UTC (rev 304524) +++ phpdoc/en/trunk/reference/reflection/reflectionfunction/export.xml 2010-10-20 02:48:22 UTC (rev 304525) @@ -17,9 +17,6 @@ <para> Exports a Reflected function. </para> - - &warn.undocumented.func; - </refsect1> <refsect1 role="parameters"> @@ -57,7 +54,7 @@ &reftitle.seealso; <para> <simplelist> - <member><methodname>ReflectionExtension::invoke</methodname></member> + <member><methodname>ReflectionFunction::invoke</methodname></member> </simplelist> </para> </refsect1> Modified: phpdoc/en/trunk/reference/reflection/reflectionfunction/invoke.xml =================================================================== --- phpdoc/en/trunk/reference/reflection/reflectionfunction/invoke.xml 2010-10-20 02:16:34 UTC (rev 304524) +++ phpdoc/en/trunk/reference/reflection/reflectionfunction/invoke.xml 2010-10-20 02:48:22 UTC (rev 304525) @@ -11,7 +11,8 @@ &reftitle.description; <methodsynopsis> <modifier>public</modifier> <type>mixed</type><methodname>ReflectionFunction::invoke</methodname> - <methodparam choice="opt"><type>string</type><parameter>args</parameter></methodparam> + <methodparam choice="opt"><type>mixed</type><parameter>parameter</parameter></methodparam> + <methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam> </methodsynopsis> <para> Invokes a reflected function. @@ -39,10 +40,49 @@ <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> - + Returns the result of the invoked function call. </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><methodname>ReflectionFunction::invoke</methodname> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +function title($title, $name) +{ + return sprintf("%s. %s\r\n", $title, $name); +} + +$function = new ReflectionFunction('title'); + +echo $function->invoke('Dr', 'Phil'); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +Dr. Phil +]]> + </screen> + </example> + </para> + </refsect1> + + <refsect1 role="notes"> + &reftitle.notes; + <note> + <para> + If the function have arguments that needs to be references, then they must be + references in the passed argument list. + </para> + </note> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> Modified: phpdoc/en/trunk/reference/reflection/reflectionfunction/invokeargs.xml =================================================================== --- phpdoc/en/trunk/reference/reflection/reflectionfunction/invokeargs.xml 2010-10-20 02:16:34 UTC (rev 304524) +++ phpdoc/en/trunk/reference/reflection/reflectionfunction/invokeargs.xml 2010-10-20 02:48:22 UTC (rev 304525) @@ -29,7 +29,8 @@ <term><parameter>args</parameter></term> <listitem> <para> - The args to invoke. + The passed arguments to the function as an array, much like + <function>call_user_func_array</function> works. </para> </listitem> </varlistentry> @@ -40,10 +41,90 @@ <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> - + Returns the result of the invoked function </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><methodname>ReflectionFunction::invokeArgs</methodname> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +function title($title, $name) +{ + return sprintf("%s. %s\r\n", $title, $name); +} + +$function = new ReflectionFunction('title'); + +echo $function->invokeArgs(Array('Dr', 'Phil')); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +Dr. Phil +]]> + </screen> + </example> + </para> + <para> + <example> + <title><methodname>ReflectionFunction::invokeArgs</methodname> with references example</title> + <programlisting role="php"> +<![CDATA[ +<?php +function get_false_conditions(Array $conditions, Array &$false_conditions) +{ + foreach($conditions as $condition) + { + if(!$condition) + { + $false_conditions[] = $condition; + } + } +} + +$function_ref = new ReflectionFunction('get_false_conditions'); + +$conditions = Array(true, false, -1, 0, 1); +$false_conditions = Array(); + +$function_ref->invokeArgs(Array($conditions, &$false_conditions)); + +var_dump($false_conditions); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +array(2) { + [0]=> + bool(false) + [1]=> + int(0) +} +]]> + </screen> + </example> + </para> + </refsect1> + + <refsect1 role="notes"> + &reftitle.notes; + <note> + <para> + If the function have arguments that needs to be references, then they must be + references in the passed argument list. + </para> + </note> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> Modified: phpdoc/en/trunk/reference/reflection/reflectionfunction/tostring.xml =================================================================== --- phpdoc/en/trunk/reference/reflection/reflectionfunction/tostring.xml 2010-10-20 02:16:34 UTC (rev 304524) +++ phpdoc/en/trunk/reference/reflection/reflectionfunction/tostring.xml 2010-10-20 02:48:22 UTC (rev 304525) @@ -16,9 +16,6 @@ <para> To string. </para> - - &warn.undocumented.func; - </refsect1> <refsect1 role="parameters"> @@ -29,15 +26,50 @@ <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> - + Returns <methodname>ReflectionFunction::export</methodname> like output for + the function. </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><methodname>ReflectionFunction::__toString</methodname> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +function title($title, $name) +{ + return sprintf("%s. %s\r\n", $title, $name); +} + +echo new ReflectionFunction('title'); +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +Function [ <user> function person ] { + @@ Command line code 1 - 1 + + - Parameters [2] { + Parameter #0 [ <required> $prefix ] + Parameter #1 [ <required> $name ] + } +} +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> - <member><methodname>ReflectionClassAbstract::clone</methodname></member> + <member><methodname>ReflectionClass::clone</methodname></member> <member><link linkend="language.oop5.magic.tostring">__toString</link></member> </simplelist> </para>

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