Files
php-doc-ru/reference/reflection/reflectionclass/getmethods.xml
Alexey Pyltsyn e83d29a635 ReflectionClass: review
git-svn-id: https://svn.php.net/repository/phpdoc/ru/trunk@344934 c90b9560-bf6c-de11-be94-00142212c4b1
2018-05-03 07:03:28 +00:00

191 lines
5.2 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 992b071c3d5890383eea943186e25b7f94ff39cd Maintainer: aur Status: ready -->
<!-- Reviewed: yes -->
<!-- $Revision$ -->
<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>Возвращает список методов в виде массива</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>array</type><methodname>ReflectionClass::getMethods</methodname>
<methodparam choice="opt"><type>int</type><parameter>filter</parameter></methodparam>
</methodsynopsis>
<para>
Возвращает список методов в виде массива.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>filter</parameter></term>
<listitem>
<para>
Фильтрация результата для включения в список только методов с определенными атрибутами.
По умолчанию фильтрации нет.
</para>
<para>
Комбинация из следующих констант через логическое ИЛИ:
<constant>ReflectionMethod::IS_STATIC</constant>,
<constant>ReflectionMethod::IS_PUBLIC</constant>,
<constant>ReflectionMethod::IS_PROTECTED</constant>,
<constant>ReflectionMethod::IS_PRIVATE</constant>,
<constant>ReflectionMethod::IS_ABSTRACT</constant>,
<constant>ReflectionMethod::IS_FINAL</constant>,
так что все методы с
<emphasis>любым</emphasis> из перечисленных
атрибутов будут возвращены.
</para>
<note>
<simpara>
Обратите внимание, что прочие побитовые операции, к примеру
<literal>~</literal> не будут работать так, как ожидается. Другими
словами, например, невозможно получить все нестатические методы.
</simpara>
</note>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Массив (<type>array</type>) объектов класса <classname>ReflectionMethod</classname>,
отражающих каждый метод.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <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>Пример фильтрации результата вызова <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>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>ReflectionClass::getMethod</methodname></member>
<member><function>get_class_methods</function></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
-->