runkit_method_rename
(PECL runkit >= 0.7.0)
runkit_method_rename — 指定したメソッドの名前を動的に変更する
説明
runkit_method_rename
( string
$classname
, string $methodname
, string $newname
) : bool注意: この関数は、 現在実行中(もしくはチェーンド)のメソッドを操作することはできません。
パラメータ
-
classname -
メソッド名を変更するクラス。
-
methodname -
変更するメソッドの名前。
-
newname -
変更後のメソッドの名前。
返り値
成功した場合に TRUE を、失敗した場合に FALSE を返します。
例
例1 runkit_method_rename() の例
<?php
class Example {
function foo() {
return "foo!\n";
}
}
// 'foo' メソッドの名前を 'bar' に変更する
runkit_method_rename(
'Example',
'foo',
'bar'
);
// 変更後の関数の出力
echo Example::bar();
?>
上の例の出力は以下となります。
foo!
参考
- runkit_method_add() - Dynamically adds a new method to a given class
- runkit_method_copy() - あるクラスのメソッドを別のクラスにコピーする
- runkit_method_redefine() - Dynamically changes the code of the given method
- runkit_method_remove() - 指定したメソッドを動的に削除する
- runkit_function_rename() - 関数名を変更する