Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130067 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 89A011A00BC for ; Tue, 10 Feb 2026 20:33:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1770755604; bh=ZrQ6tHTs5K7enXBPCMYiZmXQ8UrKjAcRqf5UXVeu6Ew=; h=Date:Subject:To:References:From:In-Reply-To:From; b=mWiuZgjEEtjDeHBzIu5xQu5X+XuOxsyYWX4abDF1r6dQau9Oc5aUi2vSuRK+ArbPw 361+KMuhYuz7WzXan5EmNUe1XiCh0n2rXYMFlslH8Dszix/h055+tZL7zs0aM2mv3c v28/vPDXmOBXFcYPr3LDykR5arFEW1Y9H9QHR4TpvuZjnfbvJU4gSfZF2shMekZCP6 QDh1vlypM+2NbAUiU62gjKO4Smz8/2gOLPnwhebMIbErlHul7QQSe6qDWvgp4viM7R +5RL/uevUXpXiVz5yea3DzB/8CxoFSuhA6SmtEDQUsdl6Dz6ukpk21CV8qWzZdEXe+ MgpFSgTSRGmJQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C0606180086 for ; Tue, 10 Feb 2026 20:33:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-a6-smtp.messagingengine.com (fhigh-a6-smtp.messagingengine.com [103.168.172.157]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 10 Feb 2026 20:33:22 +0000 (UTC) Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id 0C33114000FB for ; Tue, 10 Feb 2026 15:33:17 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Tue, 10 Feb 2026 15:33:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1770755597; x=1770841997; bh=spu/nJgq2+ y3Lkk46ad/x7ycDU5Xev0hHbwaNhJmE34=; b=sL1iJC/bQ+jUXDogwFlbcpjAK8 ECUgPytmE+M0QH2XDzzS4TVYy3UBtU6x3ObXYGWNWJOBJlgJICm55HHXJkR5AP/6 uAvpC3zlH7ujYXHymqevAZI06N5+BxBWVYOIXyfF6uqZlPZR6rnb7k4VhuJjHd+z X/Y4AwRSGW1QxFVUq2IuF9M//snfsLfmltX1o0RyIWthU51K8FAI2lwKPld2HvdM PFVi27YSXMXxDawgl4XXjqcn6L014SsisjExtBChFAl8CVFnu90ObNqo8K5+hOSx bMd3SofW7INHmiS8sHwlkyI98gdEeWU9KDEM+czqFsi/o6vrEQqj4LHrqUzA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1770755597; x=1770841997; bh=spu/nJgq2+y3Lkk46ad/x7ycDU5Xev0hHbw aNhJmE34=; b=uVv3l8tOZOQUafJjOZT2+XzYM4xnM1oBBDaLNyxHbYp8I7q2R88 utV6KFzuBvVGSIWa28YwUUvnphm8QsX/PEeIFXSdZEDqdBi7Lya90uMPR4ze0IWR OUSD6J2qHuI5/uOF38o4OYYOYQlDm9wCZxMHelbf8fv5xUdBLCEsVUQx0ZWeqwIs H6aPpqg8sjhoNlr0jypmvKSCR4kM0dox19+P71uE4pYJ6wdoPE21KA8GSz73emQg 4D26WwH/27xIrsVcXx1XORbJqSJTLc7BCVUmupAS6ReFf224tafNgsKdGw/4VikS BCG6+P3oXSGAuv/MW+H+S7/AqOr5VuUmwSQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvtddtieehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpegtkfffgggfuffvfhfhjgesrgdtreertd dvjeenucfhrhhomhepfdftohifrghnucfvohhmmhhinhhsucglkffoufhorfgnfdcuoehi mhhsohhprdhphhhpsehrfigvtgdrtghordhukheqnecuggftrfgrthhtvghrnhepieffhe fgkeekueelkedtieeftdejtdfgheettdffveehgefgkeelueehieffleejnecuffhomhgr ihhnpehgihhthhhusgdrtghomhdpphhhphdrnhgvthdpvgigthgvrhhnrghlshdrihhone cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhmshho phdrphhhphesrhifvggtrdgtohdruhhkpdhnsggprhgtphhtthhopedupdhmohguvgepsh hmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhn vght X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 10 Feb 2026 15:33:16 -0500 (EST) Content-Type: multipart/alternative; boundary="------------3YfQsyazRDN3zlbp8GUt30eg" Message-ID: <1f25d77e-224b-40d6-bf19-18dfdfc9de54@rwec.co.uk> Date: Tue, 10 Feb 2026 20:33:15 +0000 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [IDEA for RFC] let the "new" operator fail when the __construct() function returns a value. To: internals@lists.php.net References: Content-Language: en-GB In-Reply-To: From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") This is a multi-part message in MIME format. --------------3YfQsyazRDN3zlbp8GUt30eg Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 02/02/2026 18:00, Mirco Babin wrote: > Subject: [IDEA for RFC] let the "new" operator fail when the > __construct() function returns a value. > Date: 2 february 2026, 19:00h (Europe/Amsterdam) > > Hello Internals, > > The starting point of this idea is > https://github.com/php/php-src/issues/21090 Hi Miro, and welcome! I agree that allowing constructors to return a value leads to confusion, and would support deprecating and then forbidding this. However, I agree with others that this should be checked when compiling the constructor, not when running it under the "new" operator. In other words, make any method named "__construct" give the same error as a function or method marked ": void". > I've been asked to follow the RFC process. And I've been told that the > rejected PHP RFC Make constructors and destructors return void > (https://wiki.php.net/rfc/make_ctor_ret_void ) rejects my proposal. > However, my proposal is explicitly about the "new" operator and not > about return types. It does, however, concern return values. According to the current policy, it is allowed to "resurrect" a failed proposal after just 6 months: https://github.com/php/policies/blob/main/feature-proposals.rst#resurrecting-rejected-proposals That seems very short to me, but in this case it has been nearly 6 *years*. I would also note that the RFC only narrowly failed - it received 60% Yes votes, but failed to meet the threshold of two-thirds. You can see the discussion and voting threads for that previous RFC here: https://externals.io/message/110612 and https://externals.io/message/110824 It looks like there was a lot of discussion around the exact timeline, and whether to allow an explicit ": void". A new RFC could focus on *only* the "void-like behaviour", and set out a clear timeline. In other words: - In PHP 8.next, raise a Deprecation at compile-time if a method named "__construct" returns a value - In PHP 9.0, throw an Error instead > I am very very reluctant to follow the RFC process myself I would like to echo everything Tim said on this, and encourage you to start the RFC. If you look down the list of accepted RFCs at https://wiki.php.net/rfc you will see that some are long discussions of complex features; but others are just a few paragraphs. The way you laid out your e-mail already has most of what's needed: state the Problem, detail the Proposal, and assess the Impact. Regards, -- Rowan Tommins [IMSoP] --------------3YfQsyazRDN3zlbp8GUt30eg Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 02/02/2026 18:00, Mirco Babin wrote:
Subject: [IDEA for RFC] let the "new" operator fail when the
__construct() function returns a value.
Date: 2 february 2026, 19:00h (Europe/Amsterdam)

Hello Internals,

The starting point of this idea is
https://github.com/php/php-src/issues/21090


Hi Miro, and welcome!

I agree that allowing constructors to return a value leads to confusion, and would support deprecating and then forbidding this.

However, I agree with others that this should be checked when compiling the constructor, not when running it under the "new" operator. In other words, make any method named "__construct" give the same error as a function or method marked ": void".


I've been asked to follow the RFC process. And I've been told that the
rejected PHP RFC Make constructors and destructors return void
( https://wiki.php.net/rfc/make_ctor_ret_void ) rejects my proposal.
However, my proposal is explicitly about the "new" operator and not
about return types. It does, however, concern return values.


According to the current policy, it is allowed to "resurrect" a failed proposal after just 6 months: https://github.com/php/policies/blob/main/feature-proposals.rst#resurrecting-rejected-proposals That seems very short to me, but in this case it has been nearly 6 *years*.

I would also note that the RFC only narrowly failed - it received 60% Yes votes, but failed to meet the threshold of two-thirds.

You can see the discussion and voting threads for that previous RFC here: https://externals.io/message/110612 and https://externals.io/message/110824

It looks like there was a lot of discussion around the exact timeline, and whether to allow an explicit ": void". A new RFC could focus on *only* the "void-like behaviour", and set out a clear timeline. In other words:

- In PHP 8.next, raise a Deprecation at compile-time if a method named "__construct" returns a value
- In PHP 9.0, throw an Error instead


I am very very reluctant to follow the RFC process myself


I would like to echo everything Tim said on this, and encourage you to start the RFC.

If you look down the list of accepted RFCs at https://wiki.php.net/rfc you will see that some are long discussions of complex features; but others are just a few paragraphs. The way you laid out your e-mail already has most of what's needed: state the Problem, detail the Proposal, and assess the Impact.


Regards,

-- 
Rowan Tommins
[IMSoP]
--------------3YfQsyazRDN3zlbp8GUt30eg--