Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130132 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 D25EA1A00BC for ; Mon, 23 Feb 2026 08:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1771836189; bh=rfAXvfjnYRpVo7gdPXFpSGAjT3ls1kRcrkoJrnWM3AE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=UYCFyQBV5xpe5ilbMRtGT5bI9jCfA8Jb3Lx/g68eLNN97XlBHdNtADq1XUGoS4JNW cQY1LkU14xjiumDqHhLRQSoiERTmz15ksLs/psGEwHzDQOKcIb1TiJ9iMEPOug5Nbd L588Z1qDMVnXZmiWWbl97MoJhupdKPnRIvr/83FWI0kFwuukscjD1Jm163hNyFFXWC Ep21o5FP6H2XGjgZlU157omKb8dQ7gvHuc4e+T/auIwTW1aGCAQD2jiTcNPbAYCEXE rQrOqEPrq/QMyYrP24WqVnvpEAxBpZ6SfsFJl3IY2hWGw3Yo9DeVg0Mxt1CM8CZymc Yl7lIOp7FSV5Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B8554180040 for ; Mon, 23 Feb 2026 08:43:08 +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.2 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_40, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) (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 ; Mon, 23 Feb 2026 08:43:08 +0000 (UTC) Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-40ede943bf0so2428338fac.2 for ; Mon, 23 Feb 2026 00:43:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771836182; cv=none; d=google.com; s=arc-20240605; b=XVMsbDjdOX/9fdVCtrEoOuOeZaULJc8Tjw3YVX1rJ+rci+UkrEFGv69SBcAqlJo3p6 ksc96dAefaU3OcIGaaKfke0tlwEHjsEvQc2OsFhnwDqDsFOiMAdk9RFfx8RIL2qQpPk4 BBdE/loi3Vo5Hw5YViD9rIN+LEJAV4QKBw7RrUZ21cPnQ8sOEjLLkyeGH24Je3RDaz7p zE0bwc98LA12EFCIAJv2Vt/0N8Mgyzx8xbRXBX9fTyFqVJ+2uuG7xxjvlOMXChyPSPSA aXEBms1uiEHb678/R1+j5JRqd1MGTaESAuvvvNihr3UpWuDwoGwY52/HXVNN9gkZy3zE yIdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=bwEW6dTxq+tY4OATpD3Pe9Dk/LEWBBbbwSTJG66MX7Q=; fh=0un1hNQkIQnxRVmSrptHpYePKulyS9pFxhu85Wb7djM=; b=TYNOzDnOa/yfOURoLZcpFWL/vH/rh1TGJE3qJb//VCcRJVoUR8G+98Hsf0lDEclKwA eFHwFFhu9foxlEiyMGIprFBuutfS7O/ug61uwZDAYrGkMhtRhzYUAh5o/xUWbm/iB3rX 3n0nhAUSYTwTPCRggObIbvYWFm/GUKgpOK3JEsAHAuDQZLedTwKL1Bpt/jLBP7WvJj7J OV863311jdT/ZGleTzyU7z8uW4IAVzimp9D+IxaEOfNIbNR1+HS/+U+xBly1KxA/8754 GWY8v0ryBy20s/ASMb74wANJTVVHB2MkgQBJYzD0+swgdICRES0/bTRab5LGAX/sSMGi Cq8A==; darn=lists.php.net ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771836182; x=1772440982; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=bwEW6dTxq+tY4OATpD3Pe9Dk/LEWBBbbwSTJG66MX7Q=; b=iUhtemRfSa6dfiXukf3NqAjzkw7frxBp26iWHz7/ffnmI6KA4mVrwPQeTha17343RH LLASF4TpKel5Jg9PCre2mtUJEQeOliRjJZGElxrnaPRT9i2GLPnFwhDreVn1fFSDzL7o aYN2F98Cp7XQ3nMvDYJmaTXVa9mwkw1eS+EBdoIAlO2K8tat/n0h4KCJbq3tuQdypRf8 WTd6o5wWrUNMJ9cHjb8UuVNK50XqYLPg6XGQUxWkWJ0m4tYv+nbd0lsLu7wv1dBfr2VE sMs3bZcw6is3zRugyGi6J+kUJmfLSPV5qu3s8XrD2BTDEKnhAsShbKyoWh6qc+4F8BBF FhSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771836182; x=1772440982; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bwEW6dTxq+tY4OATpD3Pe9Dk/LEWBBbbwSTJG66MX7Q=; b=lWu7ihz3MR/OUr1bjCRLjSPHrWcJe9sBeQx14fYj0kHODLHSf2XXnScxLZR4KU4KVs DFI1FICnD/hRwSU75f3gSW9D66OHs87orAETmzb7nGQrEG8oBsVs9pl2kq5kXnKrfnpQ AfkFYCC2vu7YcnRICn8yZiQMKIGF5xMOuPIwe+fXnrcX2axcGM0PjgodeEkRw/HRR2VU wgzaWtrg9hjWqe80ElugnYNLy20qq3VUX+pR4NBNLhx3IH3FyAxpKCPw6m7nwByweRAy 196+oEOFn7OMgVk0uPj2/C0x9duCfmM9x/CrYzaJU6wJiPMNvHA4TmU/JxcyVmkFVH8k BVgQ== X-Gm-Message-State: AOJu0YxhZaMVpwqu+WLfBJUBG118KUylFd3ppLr+WrLm3TM5Me+3a/41 OAuqszZU2ylYkmlJiS+9JmZFA6S3LJLMnvO1JXcgr2j44VnQFtmMtCoiOlcJ49qx39jDU55d0eX vWlEyTuhvNDOl1EFDWrkjTsjEG2xWI5kh0sx3 X-Gm-Gg: AZuq6aKO6Fjw/qrogbXY6K0FhniDi9+JNBb8856yFV7pKi1seUtTuHo9EAKai5FfFSR LmLtdNSV1Ar3cnFrjKvgx7BWrJ3zea2v5M+Lef7JqgfN7hFKPsRY/ICtkklMY1W2xfd+3OJwUH3 WEvvGG5l5l6neCTwmoTzJDMHC/zlm1Ve4ySqElX+ANqVQIfcP1kgb3lx0Xr2DRTf6j6FV9oSLZW MB2qwwZGSuRcZN/CEsSFlZKYDtVny/OyAStL68n7OJp9ic+ppzfUMz4TPQbELHWWOKwoBJQnQkT mDYBBFvUZsllzAqS9QBJ/auUcofV/vQirGtN X-Received: by 2002:a05:6870:a114:b0:409:57ae:54e4 with SMTP id 586e51a60fabf-4157abe967fmr3830572fac.9.1771836182473; Mon, 23 Feb 2026 00:43:02 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <1f25d77e-224b-40d6-bf19-18dfdfc9de54@rwec.co.uk> <453bc043-b4ee-423e-9561-55510f5c20a7@rwec.co.uk> <6412E222-9B0F-4139-A6F9-7D0C686197BF@rwec.co.uk> <88259C1D-1D31-4FB1-8CA8-1F704378467D@rwec.co.uk> In-Reply-To: <88259C1D-1D31-4FB1-8CA8-1F704378467D@rwec.co.uk> Date: Mon, 23 Feb 2026 09:42:51 +0100 X-Gm-Features: AaiRm53jFWFBoYJdgi6Po_rKeHR-lhZ2YszmoA-TI5w08vyl_wHb7xBBbJCAhJY Message-ID: Subject: Re: [PHP-DEV] [IDEA for RFC] let the "new" operator fail when the __construct() function returns a value. To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" From: mirco.babin@gmail.com (Mirco Babin) Op za 21 feb 2026 om 17:28 schreef Rowan Tommins [IMSoP] : > > On 20 February 2026 16:07:01 GMT, Mirco Babin wrote: > >Failing early is not always possible. The compiler can not always infere > >the correct return type. > > PHP defines "void" separately from "null", precisely so that the compiler > doesn't need to infer anything about the returned value. All it has to do > is distinguish "return;" from "return some_expression;" > > Example: https://3v4l.org/cTaBP > That is a very good find. Are the following claims correct? 1) The example given would imply that void is not a type. ```php __construct(...$args); if ($__constructReturnValue !== void) { // PHP 8.6: Deprecated: Returning a value from the // __construct() constructor is deprecated. // PHP 9: throw new ConstructorError( // 'The __construct() constructor must not // return a value.'); } ``` 4) That would also imply that the fail early of the implicit ": void" return type declaration is true for all cases, both typed and untyped. In all cases it would be a compile error, because the compiler only checks "return something;" vs. "return;". It would never throw a TypeError at runtime. Kind regards, Mirco Babin