« ReflectionClass::markLazyObjectAsInitialized
ReflectionClass::newInstanceArgs »

ReflectionClass::newInstance

(PHP 5, PHP 7, PHP 8)

ReflectionClass::newInstance — 指定した引数でクラスの新しいインスタンスを作成する

説明

public function ReflectionClass::newInstance(mixed ...$args): object

クラスの新しいインスタンスを作成します。指定した引数をクラスのコンストラクタに渡します。

パラメータ

args

可変長の引数を受け付け、それを call_user_func() と同じ方式でクラスのコンストラクタに渡します。

戻り値

エラー / 例外

コンストラクタが public でない場合は ReflectionException が発生します。

クラスにコンストラクタがないときに args を指定すると ReflectionException が発生します。

参考

関連キーワード:
ReflectionClass   インスタンス   コンストラクタ   newInstance   args   newInstanceArgs   ReflectionException   markLazyObjectAsInitialized   mixed   可変   call   user   func   方式   参考   newInstanceWithoutConstructor   起動
関連する関数・ページ:
reflectionclass.newinstanceargs   reflectionclass.newinstancewithoutconstructor   reflectionclass.getconstructor   reflectionclass.getparentclass   reflectionclass.isuserdefined   reflectionclass.getfilename