Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130043 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 2A9E21A00BC for ; Fri, 6 Feb 2026 23:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1770422052; bh=Xb/OuG3AHq7HvUSlYH0QVmedJY2V5GTk5PgCDjJnrkk=; h=Subject:To:References:From:Date:In-Reply-To:From; b=bxLxa3MWWyLkyoXAldCHy6+TPCV2TJRZfz4qKbXdx/r20CDWY13umTUij++SudAvx tTn76Ukg+tRVKmOwVhPO4r0VrN2ts9Ye98/UXWcgm3724JDR8qfW8VkcGkvjRTYNYa q8ys9CRH6K8paLlCNSj/YxHKtK24//Ikn79xMOhHe8tEy9O6fIteQZRm/4kAjTKAXu IfBm88t5XJX/1xZn1Kl2lnEPNTmnzKyagnqyIWWs+u4F0FuS7Telb0Ah0EHSEwxeTX aj7n/IxU415thkU9Ww4zZ8CQfQuVicBFZy/0J6Ndz+N7+W4nwTLdHoYEfs7KQcTdUF yy2L7uXhyi5kQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8F347180078 for ; Fri, 6 Feb 2026 23:54:11 +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=2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING, HTML_MESSAGE,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from zebra.cherry.relay.mailchannels.net (zebra.cherry.relay.mailchannels.net [23.83.223.195]) (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 ; Fri, 6 Feb 2026 23:53:59 +0000 (UTC) Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id D9EAC92138E for ; Fri, 06 Feb 2026 23:53:42 +0000 (UTC) Received: from nl1-ss105.a2hosting.com (100-123-122-105.trex-nlb.outbound.svc.cluster.local [100.123.122.105]) (Authenticated sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id 64002921F02 for ; Fri, 06 Feb 2026 23:53:41 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; d=mailchannels.net; s=arc-2022; cv=none; t=1770422021; b=kxEJtVf6f6jxEAuVT4zvkKxMQP+NhXkZoLPhwQCZ31yTkqYulJX+OAjTUoJqCEUi3CQvtS ampCvwWVkNWvHAG7la4pKcad8FYz+Tj8apvcjN+AGrnrYQmFon5gFGf9hw4Q4BI3dDDFOn 15mzjVGCk/9Lkbmf07ZzMibyvBzS0HyTySkHPKbPCLjq4PZK/iSgmdDreCqViuNCUKP1dc 1IyVlM3vCAW3rrLpli7QvoOGLTlRHqwWxOqs1Kxsdna433tu13yG4eNyxoEfaM2ICoLv24 V3R/dAlupsSSPPBAqrjW6NGVdUuMqi8FKak/Pc2HibC9rVYWvr8tOFUxrLAqwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1770422021; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=COja6R+bMGgbxhoThs+Z5K7M5UdGcxD7qVJuOgbG2p4=; b=hNyBqLi+/WkSbjJb2KelKkNUGs5D9VtmlChk6+F9B+mXepQ5rUhWo7pU/MNbILtu8ouSXZ +itONX1hGjYA18/OtAT51oYWbVofZolcBLvtMGhyfNcCOLSmHTDmd5n4ebQEVCR189ARKP wFezfVKV2B3C97P18zu7v4qfj73BJ3ONu7tA8Ylr4C/v5gEy9lVgM+YcfyNnMEzG3uZZqV lFX1G8348yA6WlsineUd/xGQDRE1e2tpNGureo+/S5DIKDNZryTaYbcA/sb3cmVhZCYg7i 0I+yNbEhn+DG/AQL/rPFylmlDslbyBei6b8OMGYaPkLUXBB/NroqHa19LUBa7Q== ARC-Authentication-Results: i=1; rspamd-79bdc9947c-g9jv4; auth=pass smtp.auth=a2hosting smtp.mailfrom=php-internals_nospam@adviesenzo.nl X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl X-MC-Relay: Neutral X-MailChannels-SenderId: a2hosting|x-authuser|juliette@adviesenzo.nl X-MailChannels-Auth-Id: a2hosting X-Cellar-Keen: 1681a95e3e1dc7dd_1770422022080_3310095450 X-MC-Loop-Signature: 1770422022080:2661023265 X-MC-Ingress-Time: 1770422022080 Received: from nl1-ss105.a2hosting.com (nl1-ss105.a2hosting.com [85.187.142.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.123.122.105 (trex/7.1.3); Fri, 06 Feb 2026 23:53:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=adviesenzo.nl; s=default; h=Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=COja6R+bMGgbxhoThs+Z5K7M5UdGcxD7qVJuOgbG2p4=; b=kCV3Ld+Y+crnFXmzSqIxzhqvnJ +N0KjsHp65pxw8sOHUVvTfTkA7SJLhlLhGc2zOMBFW9Y44czhMeFjTmdSBcC+La7UoS0AgTt/lQ+o G44wneK+7bdtyK+gCTdo+FtWjwEZok4SdefsKCl7kr8Wo1xp1sVGOEfK6ZTG+Qwol3Gk=; Received: from mailnull by nl1-ss105.a2hosting.com with spam-scanner (Exim 4.99.1) (envelope-from ) id 1voVdr-00000008Xtd-2PRP for internals@lists.php.net; Sat, 07 Feb 2026 00:53:39 +0100 X-ImunifyEmail-Filter-Score: 1.40 X-ImunifyEmail-Filter-Version: 3.8.21/202601230823 X-ImunifyEmail-Filter-Info: SUVfVkxfUEJMX0FDQ09VTlRfMjAgTUlNRV9UUkFDRSBCQVlF U19IQU0 gSUVfVkxfUEJMX0FDQ09VTlRfMDUgTUlEX1JIU19NQVRDSF9GUk9NIE FTTiBJRV9WTF9QQkxfRE9NQUlOXzAxIElFX1ZMX1BCTF9BQ0NPVU5UX zAxIFZFUklMT0NLX0NCIEZST01fSEFTX0ROIFRPX0ROX05PTkUgUkNW RF9UTFNfQUxMIE1JTUVfVU5LTk9XTiBSQ1ZEX0NPVU5UX09ORSBSQ1Z EX1ZJQV9TTVRQX0FVVEggRlJPTV9FUV9FTlZGUk9NIElFX1ZMX1BCTF 9FTUFJTF8wMSBSQ1BUX0NPVU5UX09ORSBBUkNfTkEgVE9fTUFUQ0hfR U5WUkNQVF9BTEw= X-ImunifyEmail-Filter-Action: no action Received: from [31.201.40.213] (port=64131 helo=[192.168.1.16]) by nl1-ss105.a2hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.99.1) (envelope-from ) id 1voVdq-00000008Xsh-2cdB for internals@lists.php.net; Sat, 07 Feb 2026 00:53:39 +0100 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: <0ece40da-762a-4190-9cc8-23ff432fd441@bastelstu.be> Message-ID: <69867F01.2070107@adviesenzo.nl> Date: Sat, 7 Feb 2026 00:53:37 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 In-Reply-To: <0ece40da-762a-4190-9cc8-23ff432fd441@bastelstu.be> Content-Type: multipart/alternative; boundary="------------040204080402010101090206" X-AuthUser: juliette@adviesenzo.nl From: php-internals_nospam@adviesenzo.nl (Juliette Reinders Folmer) This is a multi-part message in MIME format. --------------040204080402010101090206 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 6-2-2026 20:59, Tim Düsterhus wrote: > On 2/2/26 19:00, Mirco Babin wrote: >> # RFC >> >> 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. > > Personally I find the fact that it's illegal to define a return type > on `__construct()` to be a pretty good indication that the constructor > is not meant to be able to return anything. As such I'm a little > surprised by the disagreement in that RFC, though it should be noted > that a majority was in favor (just not a 2/3's majority). > FYI/Just in case anyone already wants to forbid this - there is a sniff available which will flag both constructors as well as destructors with a return type and/or when the function returns something: Universal.CodeAnalysis.ConstructorDestructorReturn Ref: https://github.com/PHPCSStandards/PHPCSExtra#universalcodeanalysisconstructordestructorreturn-wrench-books --------------040204080402010101090206 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 6-2-2026 20:59, Tim Düsterhus wrote:
On 2/2/26 19:00, Mirco Babin wrote:
# RFC

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.

Personally I find the fact that it's illegal to define a return type on `__construct()` to be a pretty good indication that the constructor is not meant to be able to return anything. As such I'm a little surprised by the disagreement in that RFC, though it should be noted that a majority was in favor (just not a 2/3's majority).


FYI/Just in case anyone already wants to forbid this - there is a sniff available which will flag both constructors as well as destructors with a return type and/or when the function returns something: Universal.CodeAnalysis.ConstructorDestructorReturn

Ref: https://github.com/PHPCSStandards/PHPCSExtra#universalcodeanalysisconstructordestructorreturn-wrench-books
--------------040204080402010101090206--