1
0
mirror of https://github.com/php/doc-ru.git synced 2026-04-25 00:08:24 +02:00
Files
archived-doc-ru/reference/reflection/reflectionfunction/construct.xml
T
Alexey Pyltsyn 72ffac9a22 ReflectionFunction: review
git-svn-id: https://svn.php.net/repository/phpdoc/ru/trunk@344937 c90b9560-bf6c-de11-be94-00142212c4b1
2018-05-03 07:50:43 +00:00

207 lines
5.0 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: d8b968e63cba67a082e6e37aee1ebe7821b41258 Maintainer: tmn Status: ready -->
<!-- Reviewed: yes Maintainer: lex -->
<!-- $Revision$ -->
<refentry xml:id="reflectionfunction.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionFunction::__construct</refname>
<refpurpose>Конструктор класса ReflectionFunction</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <methodname>ReflectionFunction::__construct</methodname>
<methodparam><type>mixed</type><parameter>name</parameter></methodparam>
</methodsynopsis>
<para>
Создает объект класса <classname>ReflectionFunction</classname>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>name</parameter></term>
<listitem>
<para>
Имя функции для отражения или <link linkend="functions.anonymous">замыкание</link>.
</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>, если аргумент
<parameter>name</parameter> не содержит допустимой функции.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>5.3.0</entry>
<entry>
<parameter>name</parameter> теперь может быть <link
linkend="functions.anonymous">замыканием</link>.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <methodname>ReflectionFunction::__construct</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
/**
* Простой счетчик
*
* @return int
*/
function counter1()
{
static $c = 0;
return ++$c;
}
/**
* Другой счетчик
*
* @return int
*/
$counter2 = function()
{
static $d = 0;
return ++$d;
};
function dumpReflectionFunction($func)
{
// Вывод основной информации
printf(
"\n\n===> %s функция '%s'\n".
" объявлена в %s\n".
" строки с %d по %d\n",
$func->isInternal() ? 'internal' : 'user-defined',
$func->getName(),
$func->getFileName(),
$func->getStartLine(),
$func->getEndline()
);
// Печать документации
printf("---> Документация:\n %s\n", var_export($func->getDocComment(), 1));
// Вывод статических переменных
if ($statics = $func->getStaticVariables())
{
printf("---> Статические переменные: %s\n", var_export($statics, 1));
}
}
// Создание объекта класса ReflectionFunction
dumpReflectionFunction(new ReflectionFunction('counter1'));
dumpReflectionFunction(new ReflectionFunction($counter2));
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
===> user-defined функция 'counter1'
объявлена в Z:\reflectcounter.php
строки с 7 по 11
---> Документация:
'/**
* Простой счетчик
*
* @return int
*/'
---> Статические переменные: array (
'c' => 0,
)
===> user-defined функция '{closure}'
объявлена в Z:\reflectcounter.php
строки с 18 по 23
---> Документация:
'/**
* Другой счетчик
*
* @return int
*/'
---> Статические переменные: array (
'd' => 0,
)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>ReflectionMethod::__construct</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
-->