mirror of
https://github.com/php/doc-pl.git
synced 2026-03-25 07:32:14 +01:00
172 lines
4.0 KiB
XML
172 lines
4.0 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: ec2fe9a592f794978114ef5021db9f1d00c2e05d Maintainer: sobak Status: ready -->
|
|
<!-- $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>Tworzy obiekt ReflectionFunction</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<constructorsynopsis role="ReflectionFunction">
|
|
<modifier>public</modifier> <methodname>ReflectionFunction::__construct</methodname>
|
|
<methodparam><type class="union"><type>Closure</type><type>string</type></type><parameter>function</parameter></methodparam>
|
|
</constructorsynopsis>
|
|
<para>
|
|
Tworzy obiekt <classname>ReflectionFunction</classname>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>function</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Nazwa funkcji lub <link linkend="functions.anonymous">domknięcie</link>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<para>
|
|
Rzuca <classname>ReflectionException</classname> jeśli parametr <parameter>function</parameter>
|
|
nie zawiera poprawnej funkcji.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Przykład użycia <methodname>ReflectionFunction::__construct</methodname></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
/**
|
|
* Prosty licznik
|
|
*
|
|
* @return int
|
|
*/
|
|
function licznik1()
|
|
{
|
|
static $c = 0;
|
|
return ++$c;
|
|
}
|
|
|
|
/**
|
|
* Inny prosty licznik
|
|
*
|
|
* @return int
|
|
*/
|
|
$licznik2 = function()
|
|
{
|
|
static $d = 0;
|
|
return ++$d;
|
|
|
|
};
|
|
|
|
function dumpReflectionFunction($func)
|
|
{
|
|
// Wyświetl podstawowe informacje
|
|
printf(
|
|
"\n\n===> Funkcja %s '%s'\n".
|
|
" zadeklarowana w %s\n".
|
|
" linie %d to %d\n",
|
|
$func->isInternal() ? 'wbudowana' : 'zdefiniowana przez użytkownika',
|
|
$func->getName(),
|
|
$func->getFileName(),
|
|
$func->getStartLine(),
|
|
$func->getEndline()
|
|
);
|
|
|
|
// Wyświetl komentarz dokumentujący
|
|
printf("---> Dokumentacja:\n %s\n", var_export($func->getDocComment(), 1));
|
|
|
|
// Wyświetl zmienne statyczne jeśli istnieją
|
|
if ($statics = $func->getStaticVariables())
|
|
{
|
|
printf("---> Zmienne statyczne: %s\n", var_export($statics, 1));
|
|
}
|
|
}
|
|
|
|
// Stwórz obiekt klasy ReflectionFunction
|
|
dumpReflectionFunction(new ReflectionFunction('licznik1'));
|
|
dumpReflectionFunction(new ReflectionFunction($licznik2));
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
===> Funkcja zdefiniowana przez użytkownika 'licznik1'
|
|
zadeklarowana w Z:\reflectcounter.php
|
|
linie 7 to 11
|
|
---> Dokumentacja:
|
|
'/**
|
|
* Prosty licznik
|
|
*
|
|
* @return int
|
|
*/'
|
|
---> Zmienne statyczne: array (
|
|
'c' => 0,
|
|
)
|
|
|
|
|
|
===> Funkcja zdefiniowana przez użytkownika '{closure}'
|
|
zadeklarowana w Z:\reflectcounter.php
|
|
linie 18 to 23
|
|
---> Dokumentacja:
|
|
'/**
|
|
* Inny prosty licznik
|
|
*
|
|
* @return int
|
|
*/'
|
|
---> Zmienne statyczne: 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">Konstruktory</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
|
|
-->
|