mirror of
https://github.com/php/doc-ru.git
synced 2025-08-15 23:42:35 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/ru/trunk@321924 c90b9560-bf6c-de11-be94-00142212c4b1
138 lines
3.7 KiB
XML
138 lines
3.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- EN-Revision: 8c6d47907a700e7d824c6b02108d631e5cc1091f Maintainer: aur Status: ready -->
|
||
<!-- Reviewed: yes -->
|
||
<!-- $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>Возвращает свойства</refpurpose>
|
||
</refnamediv>
|
||
|
||
<refsect1 role="description">
|
||
&reftitle.description;
|
||
<methodsynopsis>
|
||
<modifier>public</modifier> <type>array</type><methodname>ReflectionClass::getProperties</methodname>
|
||
<methodparam choice="opt"><type>int</type><parameter>filter</parameter></methodparam>
|
||
</methodsynopsis>
|
||
<para>
|
||
Возвращает reflected (отражённые) свойства.
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="parameters">
|
||
&reftitle.parameters;
|
||
<para>
|
||
<variablelist>
|
||
<varlistentry>
|
||
<term><parameter>filter</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Опциональный фильтр, позволяющий возвращать только желаемые типы свойств. Он настраивается
|
||
с помощью <link linkend="reflectionproperty.constants.modifiers">констант ReflectionProperty</link>,
|
||
по умолчанию позволяет возвращать свойства всех типов.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
</variablelist>
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="returnvalues">
|
||
&reftitle.returnvalues;
|
||
<para>
|
||
Массив объектов класса <classname>ReflectionProperty</classname>.
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="examples">
|
||
&reftitle.examples;
|
||
<example xml:id="reflectionclass.getproperties.example.filter">
|
||
<title>Пример фильтрации с помощью <function>ReflectionClass::getProperties</function></title>
|
||
<para>
|
||
В этом примере демонстрируется использование параметра
|
||
<parameter>filter</parameter>, который в данном случае не пропускает private (закрытые) свойства.
|
||
</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</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
|
||
-->
|