(PECL runkit7 >= Unknown)
runkit7_method_redefine — Dynamically changes the code of the given method
class_namemethod_nameargument_listcodemethod_name
is called
closureflagsRUNKIT7_ACC_PUBLIC,
RUNKIT7_ACC_PROTECTED or
RUNKIT7_ACC_PRIVATE optionally combined via bitwise OR with
RUNKIT7_ACC_STATIC
doc_commentreturn_typeis_strictstrict_types=1.
例1 runkit7_method_redefine() example
<?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
runkit7_method_redefine(
'Example',
'foo',
'',
'return "bar!\n";',
RUNKIT7_ACC_PUBLIC
);
// output Example::foo() (after redefine)
echo "After: " . $e->foo();
?>上の例の出力は以下となります。
Before: foo! After: bar!