1
0
mirror of https://github.com/php/doc-pl.git synced 2026-03-24 23:22:07 +01:00
Files
Maciej Sobaczewski 30c9d829e8 Sync with EN
2024-11-22 01:29:29 +01:00

192 lines
5.3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 790f63af6521908477b285ff753e454e118bb989 Maintainer: sobak Status: ready -->
<!-- $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>Tworzy obiekt ReflectionMethod</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<constructorsynopsis role="ReflectionMethod">
<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 role="ReflectionMethod">
<modifier>public</modifier> <methodname>ReflectionMethod::__construct</methodname>
<methodparam><type>string</type><parameter>classMethod</parameter></methodparam>
</constructorsynopsis>
<warning>
<simpara>
Alternatywna sygnatura jest przestarzała od PHP 8.4.0,
zamiast niej skorzystaj z <methodname>ReflectionMethod::createFromMethodName</methodname>.
</simpara>
</warning>
<para>
Tworzy obiekt <classname>ReflectionMethod</classname>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>objectOrMethod</parameter></term>
<listitem>
<para>
Nazwa klasy lub obiekt (instancja klasy), która zawiera metodę.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>method</parameter></term>
<listitem>
<para>
Nazwa metody.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>classMethod</parameter></term>
<listitem>
<para>
Nazwa klasy i nazwa metody oddzielone <literal>::</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Rzuca <classname>ReflectionException</classname> jeśli podana metoda nie istnieje.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Przykład użycia <methodname>ReflectionMethod::__construct</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
class Licznik
{
private static $c = 0;
/**
* Zwiększa licznik
*
* @final
* @static
* @access public
* @return int
*/
final public static function zwieksz()
{
return ++self::$c;
}
}
// Stwórz obiekt klasy ReflectionMethod
$method = new ReflectionMethod('Licznik', 'zwieksz');
// Wyświetl podstawowe informacje
printf(
"===> The %s%s%s%s%s%s%s method '%s' (which is %s)\n" .
" declared in %s\n" .
" lines %d to %d\n" .
" having the modifiers %d[%s]\n",
$method->isInternal() ? 'internal' : 'user-defined',
$method->isAbstract() ? ' abstract' : '',
$method->isFinal() ? ' final' : '',
$method->isPublic() ? ' public' : '',
$method->isPrivate() ? ' private' : '',
$method->isProtected() ? ' protected' : '',
$method->isStatic() ? ' static' : '',
$method->getName(),
$method->isConstructor() ? 'the constructor' : 'a regular method',
$method->getFileName(),
$method->getStartLine(),
$method->getEndline(),
$method->getModifiers(),
implode(' ', Reflection::getModifierNames($method->getModifiers()))
);
// Wyświetl komentarz dokumentujący
printf("---> Dokumentacja:\n %s\n", var_export($method->getDocComment(), true));
// Wyświetl właściwości statyczne jeśli istnieją
if ($statics= $method->getStaticVariables()) {
printf("---> Statyczne właściwości: %s\n", var_export($statics, true));
}
// Wywołaj metodę
printf("---> Wynik wywołania: ");
var_dump($method->invoke(NULL));
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
===> The user-defined final public static method 'increment' (which is a regular method)
declared in /Users/philip/cvs/phpdoc/test.php
lines 14 to 17
having the modifiers 261[final public static]
---> Dokumentacja:
'/**
* Zwiększa licznik
*
* @final
* @static
* @access public
* @return int
*/'
---> Wynik wywołania: 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">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
-->