mirror of
https://github.com/php/doc-ru.git
synced 2026-03-24 15:52:13 +01:00
171 lines
4.4 KiB
XML
171 lines
4.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- EN-Revision: 967b4787bab600be8f96129d4960ad60f47f31e7 Maintainer: tmn Status: ready -->
|
||
<!-- Reviewed: no -->
|
||
<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;
|
||
<constructorsynopsis>
|
||
<modifier>public</modifier> <methodname>ReflectionFunction::__construct</methodname>
|
||
<methodparam><type class="union"><type>Closure</type><type>string</type></type><parameter>function</parameter></methodparam>
|
||
</constructorsynopsis>
|
||
<para>
|
||
Создаёт объект класса <classname>ReflectionFunction</classname>.
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="parameters">
|
||
&reftitle.parameters;
|
||
<para>
|
||
<variablelist>
|
||
<varlistentry>
|
||
<term><parameter>function</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Имя функции для отражения или <link linkend="functions.anonymous">замыкание</link>.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
</variablelist>
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="errors">
|
||
&reftitle.errors;
|
||
<para>
|
||
Объект класса <classname>ReflectionException</classname>, если аргумент
|
||
<parameter>function</parameter> не содержит допустимой функции.
|
||
</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
|
||
-->
|