vendredi 28 février 2020

Override parent including classes from child [duplicate]

I trying to create a child class to override parent method and I want to override parent included classes.

Example of parent class:

use \App\Core\Mapping\Status;

class ParrentClass {
    function map($array) {
        return [
            'id' => $array['id'];
            'status' => Status::map($array['status_id'])
        ];
    }
}

Example of child:

use \App\Core\Mapping\Child\Status;

class ChildClass extends ParentClass {}

so when i create ChildClass instance:

$child = new ChildClass();
$result = $child->map($some_array); // [id => 1, status => instance of \App\Core\Mapping\Status]

its working but child Status not overriding ParentClass Status. Is there any way to solve this? For child->map I want to get a \App\Core\Mapping\Child\Status instance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire