When u create an child object and you want to pass a parent object as parameter on construct you can do like in the code below:
class parent {
protected $x;
protected $y;
public function __construct($x, $y) {
$this->x = $x;
$this->y = $y;
}
}
class child extends parent {
protected $z;
public function __construct($parent, $z) {
parent::__construct($parent->x, $parent->y);
$this->z = $z;
}
}
but in this case i am just multiplying parent.
Is there any way to not copy parents data and append proper object? and code to look something like this:
class child extends parent {
protected $z;
public function __construct($parent, $z) {
parent = $parent;
$this->z = $z;
}
}