[php-src] PR #19133: [draft] short constructor

From: Date: Tue, 15 Jul 2025 12:13:49 +0000
Subject: [php-src] PR #19133: [draft] short constructor
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-32449@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/19133 Author: xepozz there is PoC of short constructor syntax (inspired by Kotlin) key points: ### regular ```php class A; ``` <details><summary>becomes</summary> ```php class A {} ``` </details> ### how to express constructor with params? ```php class A(private $a, public $b, $local); ``` <details><summary>becomes</summary> ```php class A { public function __construct(private $a, public $b, $local) { } } ``` </details> ### ok, what about inheritance? ```php class A(private $a, public $b, $local) extends B; ``` <details><summary>becomes</summary> ```php class A extends B{ public function __construct(private $a, public $b, $local) { } } ``` </details> ### how to call parent constructor? ```php class A(private $a, public $b, $local) extends B($local, "string", 24*60*60, $this->a); ``` <details><summary>becomes</summary> ```php class A { public function __construct(private $a, public $b, $local) { parent::__construct($local, "string", 24*60*60, $this->a); } } ``` </details>

« previous php.git-pulls (#32449) next »