mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00

We also document the new `$filter` parameter for the `ReflectionClass` methods `::getConstants()` and `::getReflectionConstants()` and the respective constants. Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de> Closes GH-298.
155 lines
3.7 KiB
XML
155 lines
3.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="reflectionclass.getproperties" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>ReflectionClass::getProperties</refname>
|
|
<refpurpose>Gets properties</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <type>array</type><methodname>ReflectionClass::getProperties</methodname>
|
|
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>filter</parameter><initializer>&null;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Retrieves reflected properties.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>filter</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The optional filter, for filtering desired property types. It's configured using
|
|
the <link linkend="reflectionproperty.constants.modifiers">ReflectionProperty constants</link>,
|
|
and defaults to all property types.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
An array of <classname>ReflectionProperty</classname> objects.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>7.2.0</entry>
|
|
<entry>
|
|
<parameter>filter</parameter> is nullable now.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</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.modifiers">ReflectionProperty modifier constants</link></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|