cancel
Showing results for 
Search instead for 
Did you mean: 

Autogenerated Factories should implement common interface

Autogenerated Factories should implement common interface

All auto-generated factory classes, should implement common interface. 

All factories, have to have

public function create(array $data = array())

method anyway. So why they do not implement some common FactoryInterface interface?

 

3 Comments
swahjak
Senior Member

+1. I am astonished to have found this in Magento 2 and nobody seems to care. Not even talking about why there are 'auto' generators at all.

akasianmag
Frequent Visitor
An interface is not only about arguments, but also about returned type. And all factories have different return types and cannot implement the same interface
swahjak
Senior Member

The current factories do only specify a return type in @return, there is no reason why this couldn't be achieved using an interface. A scalar typed interface could still leave the return type blank, allowing both auto generated factories and custom factories to implement the same interface.

 

When creating custom factories (I actually like to write the code myself) the code could just die when upgrading magento (without a warning).