- Added parameter and return value documentation for ReflectionMethod constructor

- Updated documentation and added examples for the following ReflectionMethod methods: export, getDeclaringClass, getPrototype, invoke, invokeArgs, isDestructor, __toString

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@301478 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Joris van de Sande 2010-07-22 20:03:49 +00:00
parent 9280b06246
commit a917da5674
9 changed files with 259 additions and 39 deletions

View file

@ -11,15 +11,13 @@
&reftitle.description;
<methodsynopsis>
<methodname>ReflectionMethod::__construct</methodname>
<methodparam><type>string</type><parameter>class_or_method</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>name</parameter></methodparam>
<methodparam><type>mixed</type><parameter>class</parameter></methodparam>
<methodparam><type>string</type><parameter>name</parameter></methodparam>
</methodsynopsis>
<para>
Constructs a new <classname>ReflectionMethod</classname>.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -27,10 +25,10 @@
<para>
<variablelist>
<varlistentry>
<term><parameter>class_or_method</parameter></term>
<term><parameter>class</parameter></term>
<listitem>
<para>
Classname or object (instance of the class) that contains the method.
</para>
</listitem>
</varlistentry>
@ -38,7 +36,7 @@
<term><parameter>name</parameter></term>
<listitem>
<para>
Name of the method.
</para>
</listitem>
</varlistentry>
@ -49,7 +47,14 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.void;
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
A <classname>ReflectionException</classname> if the the given method does not exist.
</para>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="reflectionmethod.export" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionMethod::export</refname>
<refpurpose>Export</refpurpose>
<refpurpose>Export a reflection method.</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -67,6 +67,7 @@
<para>
<simplelist>
<member><methodname>ReflectionMethod::__construct</methodname></member>
<member><methodname>ReflectionMethod::__toString</methodname></member>
</simplelist>
</para>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="reflectionmethod.getdeclaringclass" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionMethod::getDeclaringClass</refname>
<refpurpose>Gets declaring class</refpurpose>
<refpurpose>Gets declaring class for the reflected method.</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,11 +14,8 @@
<void />
</methodsynopsis>
<para>
Gets the declaring class.
Gets the declaring class for the reflected method.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -29,7 +26,42 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A <classname>ReflectionClass</classname>.
A <classname>ReflectionClass</classname> object of the class that the
reflected method is part of.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>ReflectionFunction::getDeclaringClass</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?php
class HelloWorld {
protected function sayHelloTo($name) {
return 'Hello ' . $name;
}
}
$reflectionMethod = new ReflectionMethod(new HelloWorld(), 'sayHelloTo');
var_dump($reflectionMethod->getDeclaringClass());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(ReflectionClass)#2 (1) {
["name"]=>
string(10) "HelloWorld"
}
]]>
</screen>
</example>
</para>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="reflectionmethod.getmodifiers" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionMethod::getModifiers</refname>
<refpurpose>Gets modifiers</refpurpose>
<refpurpose>Gets the method modifiers</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,11 +14,8 @@
<void />
</methodsynopsis>
<para>
Gets the modifiers.
Gets the method modifiers.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -29,7 +26,58 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A numeric representation of the modifiers.
A numeric representation of the modifiers. The modifiers are listed below.
The actual meanings of these modifiers are described in the
<link linkend="reflectionmethod.constants">predefined constants</link>.
<table>
<title>ReflectionMethod modifiers</title>
<tgroup cols="2">
<thead>
<row>
<entry>value</entry>
<entry>constant</entry>
</row>
</thead>
<tbody>
<row>
<entry>1</entry>
<entry>
<link linkend="reflectionmethod.constants.is-static">ReflectionMethod::IS_STATIC</link>
</entry>
</row>
<row>
<entry>2</entry>
<entry>
<link linkend="reflectionmethod.constants.is-abstract">ReflectionMethod::IS_ABSTRACT</link>
</entry>
</row>
<row>
<entry>4</entry>
<entry>
<link linkend="reflectionmethod.constants.is-final">ReflectionMethod::IS_FINAL</link>
</entry>
</row>
<row>
<entry>256</entry>
<entry>
<link linkend="reflectionmethod.constants.is-public">ReflectionMethod::IS_PUBLIC</link>
</entry>
</row>
<row>
<entry>512</entry>
<entry>
<link linkend="reflectionmethod.constants.is-protected">ReflectionMethod::IS_PROTECTED</link>
</entry>
</row>
<row>
<entry>1024</entry>
<entry>
<link linkend="reflectionmethod.constants.is-private">ReflectionMethod::IS_PRIVATE</link>
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</refsect1>

View file

@ -4,21 +4,19 @@
<refentry xml:id="reflectionmethod.getprototype" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionMethod::getPrototype</refname>
<refpurpose>Gets prototype</refpurpose>
<refpurpose>Gets the method prototype (if there is one).</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>ReflectionMethod::getPrototype</methodname>
<modifier>public</modifier> <type>ReflectionMethod</type><methodname>ReflectionMethod::getPrototype</methodname>
<void />
</methodsynopsis>
<para>
Gets the methods prototype.
Returns the methods prototype.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -29,7 +27,7 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The prototype.
A <classname>ReflectionMethod</classname> instance of the method prototype.
</para>
</refsect1>
@ -41,6 +39,49 @@
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>ReflectionMethod::getPrototype</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?php
class Hello {
public function sayHelloTo($name) {
return 'Hello ' . $name;
}
}
class HelloWorld extends Hello {
public function sayHelloTo($name) {
return 'Hello world: ' . $name;
}
}
$reflectionMethod = new ReflectionMethod('HelloWorld', 'sayHelloTo');
var_dump($reflectionMethod->getPrototype());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(ReflectionMethod)#2 (2) {
["name"]=>
string(10) "sayHelloTo"
["class"]=>
string(5) "Hello"
}
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>

View file

@ -19,8 +19,6 @@
Invokes a reflected method.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -67,6 +65,37 @@
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>ReflectionFunction::invoke</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?php
class HelloWorld {
public function sayHelloTo($name) {
return 'Hello ' . $name;
}
}
$reflectionMethod = new ReflectionMethod('HelloWorld', 'sayHelloTo');
echo $reflectionMethod->invoke(new HelloWorld(), 'Mike');
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Hello Mike
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>

View file

@ -18,8 +18,6 @@
Invoke arguments.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -65,6 +63,37 @@
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>ReflectionFunction::invokeArgs</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?php
class HelloWorld {
public function sayHelloTo($name) {
return 'Hello ' . $name;
}
}
$reflectionMethod = new ReflectionMethod('HelloWorld', 'sayHelloTo');
echo $reflectionMethod->invokeArgs(new HelloWorld(), array('Mike'));
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Hello Mike
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>

View file

@ -14,7 +14,7 @@
<void />
</methodsynopsis>
<para>
Checks if the method is a destructor.
Checks if the method is a destructor.
</para>
</refsect1>
@ -26,7 +26,7 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&true; if the method is a destructor, otherwise false;
&true; if the method is a destructor, otherwise &false;
</para>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="reflectionmethod.tostring" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionMethod::__toString</refname>
<refpurpose>To string</refpurpose>
<refpurpose>Returns the string representation of the Reflection method object.</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,11 +14,8 @@
<void />
</methodsynopsis>
<para>
To string.
Returns the string representation of the Reflection method object.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -29,7 +26,45 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A string representation of this <classname>ReflectionMethod</classname> instance.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>ReflectionFunction::__toString</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?php
class HelloWorld {
public function sayHelloTo($name) {
return 'Hello ' . $name;
}
}
$reflectionMethod = new ReflectionMethod(new HelloWorld(), 'sayHelloTo');
echo $reflectionMethod;
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Method [ <user> public method sayHelloTo ] {
@@ /var/www/examples/reflection.php 16 - 18
- Parameters [1] {
Parameter #0 [ <required> $name ]
}
}
]]>
</screen>
</example>
</para>
</refsect1>