mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00

Reviewed in https://github.com/php/doc-en/pull/26 git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@349198 c90b9560-bf6c-de11-be94-00142212c4b1
199 lines
5.8 KiB
XML
199 lines
5.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
|
|
<refentry xml:id="function.runkit7-method-add" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>runkit7_method_add</refname>
|
|
<refpurpose>Dynamically adds a new method to a given class</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>runkit7_method_add</methodname>
|
|
<methodparam><type>string</type><parameter>classname</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>methodname</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>args</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>code</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>RUNKIT7_ACC_PUBLIC</initializer></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>doc_comment</parameter><initializer>&null;</initializer></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>return_type</parameter></methodparam>
|
|
<methodparam choice="opt"><type>bool</type><parameter>is_strict</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>runkit7_method_add</methodname>
|
|
<methodparam><type>string</type><parameter>classname</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>methodname</parameter></methodparam>
|
|
<methodparam><type>Closure</type><parameter>closure</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>RUNKIT7_ACC_PUBLIC</initializer></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>doc_comment</parameter><initializer>&null;</initializer></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>return_type</parameter></methodparam>
|
|
<methodparam choice="opt"><type>bool</type><parameter>is_strict</parameter></methodparam>
|
|
</methodsynopsis>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>classname</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The class to which this method will be added
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>methodname</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The name of the method to add
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>args</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Comma-delimited list of arguments for the newly-created method
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>code</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The code to be evaluated when <parameter>methodname</parameter>
|
|
is called
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>closure</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
A <classname>closure</classname> that defines the method.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The type of method to create, can be
|
|
<constant>RUNKIT7_ACC_PUBLIC</constant>,
|
|
<constant>RUNKIT7_ACC_PROTECTED</constant> or
|
|
<constant>RUNKIT7_ACC_PRIVATE</constant> optionally combined via bitwise OR with
|
|
<constant>RUNKIT7_ACC_STATIC</constant>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>doc_comment</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The doc comment of the method.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>return_type</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The return type of the method.
|
|
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>is_strict</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Whether the method behaves as if it were declared in a file with <literal>strict_types=1</literal>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>runkit7_method_add</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
class Example {
|
|
function foo() {
|
|
echo "foo!\n";
|
|
}
|
|
}
|
|
|
|
// create an Example object
|
|
$e = new Example();
|
|
|
|
// Add a new public method
|
|
runkit7_method_add(
|
|
'Example',
|
|
'add',
|
|
'$num1, $num2',
|
|
'return $num1 + $num2;',
|
|
RUNKIT7_ACC_PUBLIC
|
|
);
|
|
|
|
// add 12 + 4
|
|
echo $e->add(12, 4);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
16
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>runkit7_method_copy</function></member>
|
|
<member><function>runkit7_method_redefine</function></member>
|
|
<member><function>runkit7_method_remove</function></member>
|
|
<member><function>runkit7_method_rename</function></member>
|
|
<member><function>runkit7_function_add</function></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
|
|
-->
|