PHP - Interface inheritance - declaration must be compatible

后端 未结 2 1072
小蘑菇
小蘑菇 2020-12-10 06:08

I have the interface:

interface AbstractMapper
{
    public function objectToArray(ActiveRecordBase $object);
}

And classes:



        
2条回答
  •  青春惊慌失措
    2020-12-10 06:38

    Another way of implementing this would be:

    class Executor
    {
        public function objectToArray(AbstractMapper $var)
        {
            $this->convert($var);
        }
    
        private function convert(Product $var)
        {
            ...
        }
    }
    

提交回复
热议问题