Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130037 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 C0CF21A00BD for ; Fri, 6 Feb 2026 20:02:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1770408134; bh=oJSrfMq8KcBZ8JOhlUolvHq98eo+/x6392cN3IME8dA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=jGtA9z+Y/Fdz2Y/6veTKxp8zSevefKjig198OAP0ZDtiEOaSqG99TMW7X5fKw2Y09 dKSWaQZ+Mx6aYLMtn4yIhRrBsL1jlH70t5MTUs6Hamo+vpbVyGSCpMxx4w8Bjyfts0 Z0mgjvicLEQadqSebx62skNttNZGUJ53sEDdd9vN0ncSoXNyLsHqeRARH010PLg1by x/FvDN/AyMa/LV8yf49Rqj4LErV4hfSGmeIQbZO3C/u4oiEuN+5EC+WQh9f8ovRNcw mDJ3k9Yj9StvpNfSNaGlyWqphFXorTuaitk6eXfwChHFPpuvzlMQH/edHWah/t+a5Q UpKASm0RRaCvA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 914F3180088 for ; Fri, 6 Feb 2026 20:02:12 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 20:02:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1770408123; bh=ypUkIUern3CXwlgHPh12A9yYC4z8UFoPsFwLrHLfn3Y=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=kD6zU+lITkgO3933J/cuPi+VSe8goSdbUJUtGic1K3x7G2iN5JGB94cwSm/I97piG 7pM7zsh9kYI++W/3rKGP/agLuSoay5G4MNHzOEVZGYNk+aKX8Yxv2BRUGWRzwQnxkt qPJuZuzXpAf8DuCP6gM05LXFszfCBbLaF+IjVIFSe66BboVSVJAygBRTojZgK10qsh WXIo5HG2PkEZv7TtB/BEJGHIILeA7dEmqn920RHjRLULsKw9Pr47uWxCw4ucL9Ih8F c5ZM+c2COhP/EktIGKlzm0TRYUKoyEVW6/HRuVDk1d60SGiaCab2zMfp+ss519JWHf GmqJ7eDMFmLSw== Message-ID: Date: Fri, 6 Feb 2026 21:02:03 +0100 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Subject: Re: [PHP-DEV] [IDEA for RFC] let the "new" operator fail when the __construct() function returns a value. To: Mirco Babin , Ben Ramsey Cc: internals@lists.php.net References: <20260204022858.DA5F81A00BD@lists.php.net> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 2/5/26 18:40, Mirco Babin wrote: >> So, if you call `$object->__construct()`, there's no error, and you can >> get the return value, but if you do `new Foo()`, you'd get an error? > > That is correct. As mentioned in my other email, I believe it should just be an error either way. In fact I would expect the result to be quite similar to how it already is a compile-time (!) error to return something from a void function: function foo(): void { return 1; } // Fatal error: A void function must not return a value Best regards Tim Düsterhus