Rez*_*man 5 php oop interface traits
我有一个实现接口execute
方法的类.
该接口强制该execute
方法具有两个带有某些类型提示的参数.
此外,我正在使用具有execute
方法但具有不同功能和签名的特征.我使用以下方法更改了特征方法名称:
class MyClass implements MyInterface {
use MyTrait
{
execute as protected commanderExecute;
}
public function execute(SomeInterface $arg1, SomeInterface2 $arg2)
{
// do something
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试运行应用程序时,它会抛出致命错误异常,并显示以下消息:
特征方法commanderExecute尚未应用,因为与其他特征方法存在冲突...
lsh*_*has -1
尝试这个:
class MyClass implements MyInterface {
use MyTrait
{
MyTrait::execute as protected commanderExecute;
}
public function execute(SomeInterface $arg1, SomeInterface2 $arg2)
{
// do something
}
}
Run Code Online (Sandbox Code Playgroud)