PHP-Дайджест № 148 (14 – 28 января 2019)
class MotorCycle {
public $vendor;
public $cc;
public $whells = 2;
public function __construct($vendor, $cc) {
$this->vendor = $vendor;
$this->cc = $cc;
}
//other methods
}
class MyCustomMotorCycle extends MotorCycle {
public function __construct($cc, $whells) {
parent::__construct("Custom", $cc);
// $this->cc = $cc; this statement will be added within proposed realisation
$this->whells = $whells;
}
}
для кода выше предлагается следующий альтернативный синтаксис:
class MotorCycle($vendor, $cc){
public $whells = 2;
//other methods
};
class MyCustomMotorCycle($cc, $whells) extends MotorCycle("Custom", $cc){ };