Documented many undocumented ReflectionClass methods.

Removed undocumented warnings from a couple of documented methods.
Removed $default parameter from ReflectionClass::getStaticPropertyValue method documentation, as its behaviour is undefined and seems to exist only as an artefact.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@325878 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Justin Martin 2012-05-27 23:08:29 +00:00
parent 7d5c7b8c2b
commit f9202b651d
13 changed files with 462 additions and 63 deletions

View file

@ -18,8 +18,6 @@
Exports a reflected class.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -52,6 +50,58 @@
&reflection.export.return;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic usage of <methodname>ReflectionClass::export</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
class Apple {
public $var1;
public $var2 = 'Orange';
public function type() {
return 'Apple';
}
}
ReflectionClass::export('Apple');
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
Class [ <user> class Apple ] {
@@ php shell code 1-8
- Constants [0] {
}
- Static properties [0] {
}
- Static methods [0] {
}
- Properties [2] {
Property [ <default> public $var1 ]
Property [ <default> public $var2 ]
}
- Methods [1] {
Method [ <user> public method type ] {
@@ php shell code 5 - 7
}
}
}
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;

View file

@ -4,21 +4,19 @@
<refentry xml:id="reflectionclass.getconstructor" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionClass::getConstructor</refname>
<refpurpose>Gets constructor</refpurpose>
<refpurpose>Gets the constructor of the class</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>object</type> <methodname>ReflectionClass::getConstructor</methodname>
<modifier>public</modifier> <type>ReflectionMethod</type> <methodname>ReflectionClass::getConstructor</methodname>
<void />
</methodsynopsis>
<para>
Gets the constructor from a class.
Gets the constructor of the reflected class.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -29,7 +27,36 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A <classname>ReflectionMethod</classname> object.
A <classname>ReflectionMethod</classname> object reflecting the class' constructor.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic usage of <methodname>ReflectionClass::getConstructor</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
$class = new ReflectionClass('ReflectionClass');
$constructor = $class->getConstructor();
var_dump($constructor);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(ReflectionMethod)#2 (2) {
["name"]=>
string(11) "__construct"
["class"]=>
string(15) "ReflectionClass"
}
]]>
</screen>
</example>
</para>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="reflectionclass.getextension" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionClass::getExtension</refname>
<refpurpose>Gets extension info</refpurpose>
<refpurpose>Gets a <classname>ReflectionExtension</classname> object for the extension which defined the class</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,11 +14,9 @@
<void />
</methodsynopsis>
<para>
Gets an extensions <classname>ReflectionExtension</classname> object.
Gets a <classname>ReflectionExtension</classname> object for the extension which defined the class.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -29,7 +27,35 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A <classname>ReflectionExtension</classname> object.
A <classname>ReflectionExtension</classname> object representing the extension which defined the class,
or &null; for user-defined classes.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic usage of <methodname>ReflectionClass::getExtension</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
$class = new ReflectionClass('ReflectionClass');
$extension = $class->getExtension();
var_dump($extension);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(ReflectionExtension)#2 (1) {
["name"]=>
string(10) "Reflection"
}
]]>
</screen>
</example>
</para>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="reflectionclass.getextensionname" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionClass::getExtensionName</refname>
<refpurpose>Gets an extensions name</refpurpose>
<refpurpose>Gets the name of the extension which defined the class</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,11 +14,9 @@
<void />
</methodsynopsis>
<para>
Gets an extensions name.
Gets the name of the extension which defined the class.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -29,7 +27,31 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The extensions name.
The name of the extension which defined the class, or &false; for user-defined classes.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic usage of <methodname>ReflectionClass::getExtensionName</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
$class = new ReflectionClass('ReflectionClass');
$extension = $class->getExtensionName();
var_dump($extension);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
string(10) "Reflection"
]]>
</screen>
</example>
</para>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="reflectionclass.getmethod" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionClass::getMethod</refname>
<refpurpose>Gets a ReflectionMethod</refpurpose>
<refpurpose>Gets a <classname>ReflectionMethod</classname> for a class method.</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,11 +14,9 @@
<methodparam><type>string</type><parameter>name</parameter></methodparam>
</methodsynopsis>
<para>
Gets a <classname>ReflectionMethod</classname> about a method.
Gets a <classname>ReflectionMethod</classname> for a class method.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -43,6 +41,35 @@
A <classname>ReflectionMethod</classname>.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic usage of <methodname>ReflectionClass::getMethod</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
$class = new ReflectionClass('ReflectionClass');
$method = $class->getMethod('getMethod');
var_dump($method);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(ReflectionMethod)#2 (2) {
["name"]=>
string(9) "getMethod"
["class"]=>
string(15) "ReflectionClass"
}
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;

View file

@ -4,7 +4,7 @@
<refentry xml:id="reflectionclass.getmethods" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionClass::getMethods</refname>
<refpurpose>Gets a list of methods</refpurpose>
<refpurpose>Gets an array of methods</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,11 +14,8 @@
<methodparam choice="opt"><type>string</type><parameter>filter</parameter></methodparam>
</methodsynopsis>
<para>
Gets a list of methods.
Gets an array of methods for the class.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -28,6 +25,10 @@
<varlistentry>
<term><parameter>filter</parameter></term>
<listitem>
<para>
Filter the results to include only methods with certain attributes. Defaults
to no filtering.
</para>
<para>
Any combination of <constant>ReflectionMethod::IS_STATIC</constant>,
<constant>ReflectionMethod::IS_PUBLIC</constant>,
@ -45,7 +46,101 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
An <type>array</type> of methods.
An <type>array</type> of <classname>ReflectionMethod</classname> objects
reflecting each method.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic usage of <methodname>ReflectionClass::getMethods</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
class Apple {
public function firstMethod() { }
final protected function secondMethod() { }
private static function thirdMethod() { }
}
$class = new ReflectionClass('Apple');
$methods = $class->getMethods();
var_dump($methods);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(3) {
[0]=>
&object(ReflectionMethod)#2 (2) {
["name"]=>
string(11) "firstMethod"
["class"]=>
string(5) "Apple"
}
[1]=>
&object(ReflectionMethod)#3 (2) {
["name"]=>
string(12) "secondMethod"
["class"]=>
string(5) "Apple"
}
[2]=>
&object(ReflectionMethod)#4 (2) {
["name"]=>
string(11) "thirdMethod"
["class"]=>
string(5) "Apple"
}
}
]]>
</screen>
</example>
</para>
<para>
<example>
<title>Filtering results from <methodname>ReflectionClass::getMethods</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
class Apple {
public function firstMethod() { }
final protected function secondMethod() { }
private static function thirdMethod() { }
}
$class = new ReflectionClass('Apple');
$methods = $class->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_FINAL);
var_dump($methods);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(2) {
[0]=>
&object(ReflectionMethod)#2 (2) {
["name"]=>
string(12) "secondMethod"
["class"]=>
string(5) "Apple"
}
[1]=>
&object(ReflectionMethod)#3 (2) {
["name"]=>
string(11) "thirdMethod"
["class"]=>
string(5) "Apple"
}
}
]]>
</screen>
</example>
</para>
</refsect1>

View file

@ -4,7 +4,7 @@
<refentry xml:id="reflectionclass.getproperty" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionClass::getProperty</refname>
<refpurpose>Gets property</refpurpose>
<refpurpose>Gets a <classname>ReflectionProperty</classname> for a class's property</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,11 +14,9 @@
<methodparam><type>string</type><parameter>name</parameter></methodparam>
</methodsynopsis>
<para>
Gets a property.
Gets a <classname>ReflectionProperty</classname> for a class's property.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -43,6 +41,35 @@
A <classname>ReflectionProperty</classname>.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic usage of <methodname>ReflectionClass::getProperty</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
$class = new ReflectionClass('ReflectionClass');
$property = $class->getProperty('name');
var_dump($property);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(ReflectionProperty)#2 (2) {
["name"]=>
string(4) "name"
["class"]=>
string(15) "ReflectionClass"
}
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;

View file

@ -12,14 +12,11 @@
<methodsynopsis>
<modifier>public</modifier> <type>mixed</type><methodname>ReflectionClass::getStaticPropertyValue</methodname>
<methodparam><type>string</type><parameter>name</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>default</parameter></methodparam>
</methodsynopsis>
<para>
Gets the static property values.
Gets the value of a static property on this class.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -30,15 +27,7 @@
<term><parameter>name</parameter></term>
<listitem>
<para>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>default</parameter></term>
<listitem>
<para>
The name of the static property for which to return a value.
</para>
</listitem>
</varlistentry>
@ -49,7 +38,34 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The value of the static property.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic usage of <methodname>ReflectionClass::getStaticPropertyValue</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
class Apple {
public static $color = 'Red';
}
$class = new ReflectionClass('Apple');
var_dump($class->getStaticPropertyValue('color'));
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
string(3) "Red"
]]>
</screen>
</example>
</para>
</refsect1>

View file

@ -14,11 +14,9 @@
<void />
</methodsynopsis>
<para>
Returns whether this class is cloneable.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -32,7 +30,44 @@
Returns &true; if the class is cloneable, &false; otherwise.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic usage of <methodname>ReflectionClass::isCloneable</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
class NotCloneable {
public $var1;
private function __clone() {
}
}
class Cloneable {
public $var1;
}
$notCloneable = new ReflectionClass('NotCloneable');
$cloneable = new ReflectionClass('Cloneable');
var_dump($notCloneable->isCloneable());
var_dump($cloneable->isCloneable());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(false)
bool(true)
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>

View file

@ -4,7 +4,7 @@
<refentry xml:id="reflectionclass.isinstantiable" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionClass::isInstantiable</refname>
<refpurpose>Checks if instantiable</refpurpose>
<refpurpose>Checks if the class is instantiable</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,11 +14,9 @@
<void />
</methodsynopsis>
<para>
Checks if the class is instanciable.
Checks if the class is instantiable.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">

View file

@ -4,7 +4,7 @@
<refentry xml:id="reflectionclass.isinterface" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionClass::isInterface</refname>
<refpurpose>Checks if interface</refpurpose>
<refpurpose>Checks if the class is an interface</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -16,9 +16,6 @@
<para>
Checks whether the class is an interface.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -32,6 +29,33 @@
&return.success;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic usage of <methodname>ReflectionClass::isInterface</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
interface SomeInterface {
public function interfaceMethod();
}
$class = new ReflectionClass('SomeInterface');
var_dump($class->isInterface());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(true)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;

View file

@ -4,7 +4,7 @@
<refentry xml:id="reflectionclass.isinternal" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionClass::isInternal</refname>
<refpurpose>Checks if internal</refpurpose>
<refpurpose>Checks if class is defined internally by an extension, or the core</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -14,11 +14,9 @@
<void />
</methodsynopsis>
<para>
Checks whether the class is internal, as opposed to user-defined.
Checks if the class is defined internally by an extension, or the core, as opposed to user-defined.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -32,6 +30,35 @@
&return.success;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic usage of <methodname>ReflectionClass::isInternal</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
$internalclass = new ReflectionClass('ReflectionClass');
class Apple {}
$userclass = new ReflectionClass('Apple');
var_dump($internalclass->isInternal());
var_dump($userclass->isInternal());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(true)
bool(false)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;

View file

@ -18,8 +18,6 @@
class constructor.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -44,6 +42,33 @@
Returns a new instance of the class.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic usage of <methodname>ReflectionClass::newInstanceArgs</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
$class = new ReflectionClass('ReflectionFunction');
$instance = $class->newInstanceArgs(array('substr'));
var_dump($instance);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(ReflectionFunction)#2 (1) {
["name"]=>
string(6) "substr"
}
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;