<?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision$ --> <refentry xml:id="function.classkit-method-redefine" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>classkit_method_redefine</refname> <refpurpose>Dynamically changes the code of the given method</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>classkit_method_redefine</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>CLASSKIT_ACC_PUBLIC</initializer></methodparam> </methodsynopsis> ¬e.classkit.selfmanipulation; &warn.experimental.func; </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>classname</parameter></term> <listitem> <para> The class in which to redefine the method </para> </listitem> </varlistentry> <varlistentry> <term><parameter>methodname</parameter></term> <listitem> <para> The name of the method to redefine </para> </listitem> </varlistentry> <varlistentry> <term><parameter>args</parameter></term> <listitem> <para> Comma-delimited list of arguments for the redefined method </para> </listitem> </varlistentry> <varlistentry> <term><parameter>code</parameter></term> <listitem> <para> The new code to be evaluated when <parameter>methodname</parameter> is called </para> </listitem> </varlistentry> <varlistentry> <term><parameter>flags</parameter></term> <listitem> <para> The redefined method can be <constant>CLASSKIT_ACC_PUBLIC</constant>, <constant>CLASSKIT_ACC_PROTECTED</constant> or <constant>CLASSKIT_ACC_PRIVATE</constant> </para> <note> <para> This parameter is only used as of PHP 5, because, prior to this, all methods were public. </para> </note> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.success; </para> </refsect1> <!-- No changelog: it's only in PECL. --> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>classkit_method_redefine</function> example</title> <programlisting role="php"> <![CDATA[ <?php class Example { function foo() { return "foo!\n"; } } // create an Example object $e = new Example(); // output Example::foo() (before redefine) echo "Before: " . $e->foo(); // Redefine the 'foo' method classkit_method_redefine( 'Example', 'foo', '', 'return "bar!\n";', CLASSKIT_ACC_PUBLIC ); // output Example::foo() (after redefine) echo "After: " . $e->foo(); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Before: foo! After: bar! ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>classkit_method_add</function></member> <member><function>classkit_method_copy</function></member> <member><function>classkit_method_remove</function></member> <member><function>classkit_method_rename</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 -->