mirror of
https://github.com/php/doc-ru.git
synced 2026-03-24 15:52:13 +01:00
197 lines
5.9 KiB
XML
197 lines
5.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- EN-Revision: 8217228b33b68819e6670c27e223edac282bfd2b 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;
|
||
<constructorsynopsis>
|
||
<modifier>public</modifier> <methodname>ReflectionMethod::__construct</methodname>
|
||
<methodparam><type class="union"><type>object</type><type>string</type></type><parameter>objectOrMethod</parameter></methodparam>
|
||
<methodparam><type>string</type><parameter>method</parameter></methodparam>
|
||
</constructorsynopsis>
|
||
<simpara>Alternative signature (not supported with named arguments):</simpara>
|
||
<constructorsynopsis>
|
||
<modifier>public</modifier> <methodname>ReflectionMethod::__construct</methodname>
|
||
<methodparam><type>string</type><parameter>classMethod</parameter></methodparam>
|
||
</constructorsynopsis>
|
||
<para>
|
||
Создаёт новый объект класса <classname>ReflectionMethod</classname>.
|
||
</para>
|
||
|
||
</refsect1>
|
||
|
||
<refsect1 role="parameters">
|
||
&reftitle.parameters;
|
||
<para>
|
||
<variablelist>
|
||
<varlistentry>
|
||
<term><parameter>objectOrMethod</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Имя класса или объект (экземпляр класса), содержащего метод.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>method</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Имя метода.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>classMethod</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
|
||
-->
|