I've got some classes, and each of those classes have a collection of static functions which returns an instance
of those classes, instead of having those functions in 20 different classes, I tried to move them to a parent class and inherit that class.
The problem is, when I use "return new self" from the parent class, it won't return the properties of the child it's been called from.
Here's a simple example of what i am trying to do -
<?php
class Personal_Details{
static function create_user(){
return new self;
}
}
class Female_User extends Personal_Details{
public $gender = "f";
}
class Male_User extends Personal_Details{
public $gender = "m";
}
$new_user = Male_User::create_user();
echo $new_user->gender;
?>
I guess I'm using the wrong logic here, but how can i make this work the way i intended to?
Thans.