1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-24 15:52:13 +01:00
Files
archived-doc-ru/reference/reflection/reflectionfunction/construct.xml
Alexey Pyltsyn b21887f9c3 Yofication
2021-01-03 21:07:35 +03:00

182 lines
4.5 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: 7f569e1f175adf1fbd0e462eba8d6bc82214c939 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="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
-->