Re: Primary Constructors

From: Date: Mon, 22 Jun 2026 18:40:56 +0000
Subject: Re: Primary Constructors
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-131474@lists.php.net to get a copy of this message
Hi Am 2026-06-22 17:15, schrieb Larry Garfield:
I don't think we should include the "secondary constructor calls primary constructor and you have to make sure it works" logic.
PHP doesn't (and cannot easily) support method overloading, thus there cannot be such a thing as “primary and secondary” constructor. It is unclear to me what you are getting at here.
However, I do think we can/should consider an init block.
At the point where extra logic is required maybe just write a plain old regular __construct() method instead of inventing yet another “method-like” construct. Best regards Tim Düsterhus

« previous php.internals (#131474) next »