Proposal fo "Code-free constructors declaration"

From: Date: Wed, 23 Jan 2019 12:32:28 +0000
Subject: Proposal fo "Code-free constructors declaration"
Groups: php.internals 
Request: Send a blank email to internals+get-103793@lists.php.net to get a copy of this message
Full description https://wiki.php.net/rfc/code_free_constructor Draft realisation https://github.com/php/php-src/compare/master...rjhdby:constructor "Code free" constructor is constructor with only purpose to directly set object properties from received parameters and, optionally, call parent constructor. Main idea is to move such constructor declaration inside class declaration. Simple example: Current syntax class A extends B{ public $prop; public function __construct($prop){ parent::__construct("BlaBla", $prop); $this->prop = $prop; } } Proposed syntax class A($prop) extends B("BlaBla", $prop) { } With respect, Andrey.

« previous php.internals (#103793) next »