svn: /phpdoc/en/trunk/reference/reflection/reflectionclass/ getproperties.xml

From: Date: Fri, 30 Apr 2010 19:04:16 +0000
Subject: svn: /phpdoc/en/trunk/reference/reflection/reflectionclass/ getproperties.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-6547@lists.php.net to get a copy of this message
philip Fri, 30 Apr 2010 19:04:16 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=298817 Log: Documented this method. Also note that the methodsynopsis was updated. Changed paths: U phpdoc/en/trunk/reference/reflection/reflectionclass/getproperties.xml Modified: phpdoc/en/trunk/reference/reflection/reflectionclass/getproperties.xml =================================================================== --- phpdoc/en/trunk/reference/reflection/reflectionclass/getproperties.xml 2010-04-30 18:19:57 UTC (rev 298816) +++ phpdoc/en/trunk/reference/reflection/reflectionclass/getproperties.xml 2010-04-30 19:04:16 UTC (rev 298817) @@ -10,15 +10,12 @@ <refsect1 role="description"> &reftitle.description; <methodsynopsis> - <modifier>public</modifier> <type>ReflectionProperty</type><methodname>ReflectionClass::getProperties</methodname> - <methodparam choice="opt"><type>string</type><parameter>filter</parameter></methodparam> + <modifier>public</modifier> <type>array</type><methodname>ReflectionClass::getProperties</methodname> + <methodparam choice="opt"><type>int</type><parameter>filter</parameter></methodparam> </methodsynopsis> <para> - Gets the properties. + Retrieves reflected properties. </para> - - &warn.undocumented.func; - </refsect1> <refsect1 role="parameters"> @@ -29,7 +26,9 @@ <term><parameter>filter</parameter></term> <listitem> <para> - The optional filter. + The optional filter, for filtering desired property types. It's configured using + the <link linkend="reflectionproperty.constants">ReflectionProperty constants</link>, + and defaults to all property types. </para> </listitem> </varlistentry> @@ -40,15 +39,74 @@ <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> - A <classname>ReflectionProperty</classname>. + An array of <classname>ReflectionProperty</classname> objects. </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <example xml:id="reflectionclass.getproperties.example.filter"> + <title><function>ReflectionClass::getProperties</function> filtering example</title> + <para> + This example demonstrates usage of the optional <parameter>filter</parameter> + parameter, where it essentially skips private properties. + </para> + <programlisting role="php"> +<![CDATA[ +<?php +class Foo { + public $foo = 1; + protected $bar = 2; + private $baz = 3; +} + +$foo = new Foo(); + +$reflect = new ReflectionClass($foo); +$props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED); + +foreach ($props as $prop) { + print $prop->getName() . "\n"; +} + +var_dump($props); + +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +foo +bar +array(2) { + [0]=> + object(ReflectionProperty)#3 (2) { + ["name"]=> + string(3) "foo" + ["class"]=> + string(3) "Foo" + } + [1]=> + object(ReflectionProperty)#4 (2) { + ["name"]=> + string(3) "bar" + ["class"]=> + string(3) "Foo" + } +} +]]> + </screen> + </example> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><methodname>ReflectionClass::getProperty</methodname></member> + <member><classname>ReflectionProperty</classname></member> + <member><link linkend="reflectionproperty.constants">ReflectionProperty constants</link></member> </simplelist> </para> </refsect1>

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