Can you override interface methods with different, but “compatible”, signatures?

后端 未结 7 1165
长发绾君心
长发绾君心 2021-02-07 01:32

Consider the following PHP interfaces:

interface Item {
    // some methods here
}

interface SuperItem extends Item {
    // some extra methods here, not define         


        
相关标签:
7条回答
  • 2021-02-07 02:00

    When I have a method that I may need to overload (which PHP does not support), I make sure that one of the method arguments (usually the last) is an array. In this way I can pass whatever I need to. I can then test within the function for various array elements to tell me what routine in the method I need to perform, usually in a select/case.

    0 讨论(0)
提交回复
热议问题