1
0
mirror of https://github.com/php/doc-ru.git synced 2026-04-27 09:18:07 +02:00
Files
archived-doc-ru/reference/reflection/reflectionmethod/construct.xml
T
Alexey Pyltsyn 88ddb5e946 Upd
git-svn-id: https://svn.php.net/repository/phpdoc/ru/trunk@347172 c90b9560-bf6c-de11-be94-00142212c4b1
2019-04-10 13:03:37 +00:00

197 lines
5.8 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: c55e85a130b71e7b85687cadd608d5a04684f3a6 Maintainer: tmn Status: ready -->
<!-- Reviewed: yes Maintainer: lex -->
<!-- $Revision$ -->
<refentry xml:id="reflectionmethod.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionMethod::__construct</refname>
<refpurpose>Конструктор класса ReflectionMethod</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <methodname>ReflectionMethod::__construct</methodname>
<methodparam><type>mixed</type><parameter>class</parameter></methodparam>
<methodparam><type>string</type><parameter>name</parameter></methodparam>
</methodsynopsis>
<methodsynopsis>
<modifier>public</modifier> <methodname>ReflectionMethod::__construct</methodname>
<methodparam><type>string</type><parameter>class_method</parameter></methodparam>
</methodsynopsis>
<para>
Создает новый объект класса <classname>ReflectionMethod</classname>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>class</parameter></term>
<listitem>
<para>
Имя класса или объект (экземпляр класса), содержащего метод.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>name</parameter></term>
<listitem>
<para>
Имя метода.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>class_method</parameter></term>
<listitem>
<para>
Имена класса и метода, разделенные <literal>::</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.void;
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Исключение <classname>ReflectionException</classname> выбрасывается, если
заданный метод не существует.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>
Пример использования <methodname>ReflectionMethod::__construct</methodname>
</title>
<programlisting role="php">
<![CDATA[
<?php
class Counter
{
private static $c = 0;
/**
* Счетчик
*
* @final
* @static
* @access public
* @return int
*/
final public static function increment()
{
return ++self::$c;
}
}
// Создание экземпляра класса ReflectionMethod
$method = new ReflectionMethod('Counter', 'increment');
// Вывод основной информации
printf(
"===> %s%s%s%s%s%s%s метод '%s' (%s)\n" .
" объявлен в %s\n" .
" строки с %d по %d\n" .
" имеет модификаторы %d[%s]\n",
$method->isInternal() ? 'внутренний' : 'определенный пользователем',
$method->isAbstract() ? ' абстрактный' : '',
$method->isFinal() ? ' окончательный' : '',
$method->isPublic() ? ' общедоступный' : '',
$method->isPrivate() ? ' закрытый' : '',
$method->isProtected() ? ' защищенный' : '',
$method->isStatic() ? ' статический' : '',
$method->getName(),
$method->isConstructor() ? 'конструктор' : 'обычный метод',
$method->getFileName(),
$method->getStartLine(),
$method->getEndline(),
$method->getModifiers(),
implode(' ', Reflection::getModifierNames($method->getModifiers()))
);
// Вывод doc-комментария
printf("---> Комментарий:\n %s\n", var_export($method->getDocComment(), true));
// Вывод статических переменных, если есть
if ($statics= $method->getStaticVariables()) {
printf("---> Статические переменные: %s\n", var_export($statics, true));
}
// Вызов метода
printf("---> Результат вызова метода: ");
var_dump($method->invoke(NULL));
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
===> определенный пользователем окончательный общедоступный статический метод 'increment' (обычный метод)
объявлен в /Users/philip/cvs/phpdoc/test.php
строки с 14 по 17
имеет модификаторы 261[final public static]
---> Комментарий:
'/**
* Счетчик
*
* @final
* @static
* @access public
* @return int
*/'
---> Результат вызова метода: int(1)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>ReflectionMethod::export</methodname></member>
<member><link linkend="language.oop5.decon.constructor">Конструкторы</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
-->