cancel
Showing results for 
Search instead for 
Did you mean: 

Auto-generated factories should extend each other.

0 Kudos

Auto-generated factories should extend each other.

When i have two classes. One extending the other.

class Foo {
    //Some code
}

class Bar extends Foo {
   //Some other code
}

It's common practice to pass Bar instance to functions that requires instance of Foo. For example:

magicFunction(Foo $instanceOfFoo){
    ....
}

$instanceOfBar = new Bar();

$result = magicFunction($instanceOfBar);

But, auto-generated factory of Bar doesn't extend from Foo autogenerated factory, so you can't do this:

magicFunction(FooFactory $instanceOfFooFactory){
    ....
}

$instanceOfBarFactory = new BarFactory(....);

$result = magicFunction($instanceOfBarFactory);

I think that auto-generated factory of class, that extends some other class, should extend the other class factory as well.