classkit_method_copy

(PECL)

classkit_method_copy -- Copies a method from class to another

説明

bool classkit_method_copy ( string dClass, string dMethod, string sClass [, string sMethod] )

警告

この関数は、 実験的なステータスにあります。これは、この関数の 動作、関数名、ここで書かれていること全てがPHPの将来のバージョンで予告 なく変更される可能性があることを意味します。注意を喚起するとともに自分 のリスクでこの関数を使用してください。

パラメータ

dClass

Destination class for copied method

dMethod

Destination method name

sClass

Source class of the method to copy

sMethod

Name of the method to copy from the source class. If this parameter is omitted, the value of dMethod is assumed.

戻り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。

例 1. classkit_method_copy() example

<?php
class Foo {
    function
example() {
        return
"foo!\n";
    }
}

class
Bar {
    
// initially, no methods
}

// copy the example() method from the Foo class to the Bar class, as baz()
classkit_method_copy('Bar', 'baz', 'Foo', 'example');

// output copied function
echo Bar::baz();
?>

上の例の出力は以下となります:

foo!

以下も参照ください

classkit_method_add()
classkit_method_redefine()
classkit_method_remove()
classkit_method_rename()