Re: Add a static initialization method to `BcMath\Number`
| From: | B.J. Scharp | Date: | Fri, 12 Jun 2026 07:19:22 +0000 |
| Subject: | Re: Add a static initialization method to `BcMath\Number` | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131209@lists.php.net to get a copy of this message | ||
On 29-05-2026 5:59 PM, Larry Garfield wrote:
On Mon, May 25, 2026, at 4:07 AM, Gina P. Banyard wrote:An idea that has always played through my head for this, was to add a syntax-alternative to "new MyClass()" in the form: "MyClass::__construct()". (In other words, make the constructor statically callable). But seeing it was dropped from the initial RFC, it's probably not be as trivial as it seems. It could even be argued that the constructor should have been a static method in the first place. I only found out today that you can call "->__construct()" on an existing object. I don't really see a use case for that, to be honest, and with readonly properties and property-promotion it's a whole snake-pit all by itself. Regards, BernardWe should instead find a solution to allow FCCs/PFAs to work on constructors and new rather than adding static factories for every possible class in existence. I restarted work on a PR to clean up the semantics of constructors that, I believe, would make it feasible to allow FCCs/PFAs on new MyClass. [1]The original PFA RFC included constructor support, but it was complicated. It was dropped from the new one that passed in order to simplify things, but I am open to re-adding it if a good approach is found. So it should certainly be possible, just a bit hard. --Larry Garfield