Cannot implement two interfaces that have the same method name

后端 未结 5 1980
[愿得一人]
[愿得一人] 2021-01-13 07:28

This doesn\'t work:

interface TestInterface
{
    public function testMethod();
}

interface TestInterface2
{
    public function testMethod();
}

class Test         


        
5条回答
  •  再見小時候
    2021-01-13 08:08

    This is not allowed, because PHP cannot be sure which interface has the method you want. In your case they are identical, but imagine if they had different parameters.

    You should reconsider your application design.

提交回复
热议问题