inherited factory method should return instances of own class not inherited class

nathanjefferson

New Member
I have a class that has a complex static factory method, lets call it ClassA. I have extended ClassA into ClassB and I want ClassB's factory method to do everything that ClassA's factory method does, except return a ClassB.\[code\]class ClassA{ static public function Factory($construct_args, $contents){ $new = new ClassA($construct_args); //Does lots of stuff with $contents }}class ClassB extends ClassA{ //specialty methods and properties}echo get_class(ClassB::Factory($construct_args, $contents);\[/code\]This should echo \[code\]ClassB\[/code\]Is there a way I can use ClassA's Factory Method without copy-pasting it to ClassB? I am using PHP5, but not 5.3.0.
 
Back
Top