uopz_implement

(PECL uopz 1, PECL uopz 2, PECL uopz 5, PECL uopz 6, PECL uopz 7 < 7.1.0)

uopz_implement実行時にインターフェイスを実装させる

説明

uopz_implement(string $class, string $interface): bool

classinterface を実装させます。

パラメータ

class

interface

戻り値

成功した場合に true を、失敗した場合に false を返します。

エラー / 例外

PHP 7.4.0 以降では、 OPcache が有効になっており、 かつ class のエントリが変更不能な場合、 uopz_implements() 関数は RuntimeException をスローするようになりました。

例1 uopz_implement() の例

<?php
interface myInterface {}

class
myClass {}

uopz_implement(myClass::class, myInterface::class);

var_dump(class_implements(myClass::class));
?>

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

array(1) {
  ["myInterface"]=>
  string(11) "myInterface"
}
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top