Php type hinting not getting along with interfaces and abstract classes?

后端 未结 3 1521
[愿得一人]
[愿得一人] 2020-12-01 18:08

I think it\'ll be much easier to see the problem in a code example than writing the question in the first place. Here is my php code:



        
3条回答
  •  旧时难觅i
    2020-12-01 18:58

    Here's an example that shows, why this is not allowed:

    method($b);
    }
    

    This would be a valid code, but it would fail, if you pass a ConcreteClass to moo, because its method ConcreteClass::method does not allow BClass.

    It is complicated, but it is easier to understand, if you see an example.

提交回复
热议问题