« ReflectionMethod::export
ReflectionMethod::getDeclaringClass »

ReflectionMethod::getClosure

(PHP 5 >= 5.4.0, PHP 7, PHP 8)

ReflectionMethod::getClosure — このメソッドに動的に作成されたクロージャを返す

説明

public function ReflectionMethod::getClosure(?object $object = null): Closure

メソッドをコールするクロージャを作成します。

パラメータ

object

staticメソッドの場合は不要、その他のメソッドの場合は必須となります。

戻り値

新しく作成した Closure を返します。

エラー / 例外

object が null なのに、 メソッドが static ではない場合、 ValueError がスローされます。

object が、 このメソッドが宣言されたクラスのインスタンスでない場合、 ReflectionException がスローされます。

変更履歴

バージョン 説明
8.0.0 object は、nullable になりました。
関連キーワード:
ReflectionMethod   クロージャ   getClosure   Closure   static   export   getDeclaringClass   必須   ValueError   宣言   インスタンス   ReflectionException   履歴   nullable   参考   一級   callable   記法
関連する関数・ページ:
reflectionmethod.export   reflectionmethod.ispublic   reflectionmethod.getdeclaringclass   reflectionmethod.createfrommethodname   reflectionmethod.isconstructor   reflectionmethod.isfinal