Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128188 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 4366F1A00BC for ; Wed, 23 Jul 2025 11:30:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753270134; bh=WkmJ32Go8PuGCSF46YWSRbD3Ue1sW+9MYR/l3EyEr2k=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=mTqLS6YhQEtRbT6zCVnmvWBmo/8BLAF7webwrE9rYP0s491CCgAo7ITibvA3L+LLt izSx+kIAZRMZ6IuZ6CWpwlTuWLanx3AJ2zCIquFh/iShUJQovdGzQ4vw14ZNiis5tK j03p9BD5OLeqYTZtIUgx5FWwCSxw2g7i4E5GkYVSSpH/SdUaR3/kBiv9+9fsj6mRBQ dUP8o8U/l+j7ZFHRXQNazwI4SGrxOZG93DrdzbbCoFDZA0oq0npNnDKSiQ07MGwCT2 q6CTz0ANK8cVNyEOLqfI+gk7EmhEMAcndF3RM6zCR/vtfld3E2LiXO2FLelni27+Dx +6xNOdbl7wEAg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 31E1F18005C for ; Wed, 23 Jul 2025 11:28:54 +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.8 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, FREEMAIL_REPLY,HTML_MESSAGE,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: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (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 ; Wed, 23 Jul 2025 11:28:53 +0000 (UTC) Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-4ab7384b108so68539901cf.0 for ; Wed, 23 Jul 2025 04:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753270238; x=1753875038; 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=nN1qMVzRHpkfA2cRuVdiCu3b2Ziq7OpXFjTGDgHu3zM=; b=CdvTpWdMJgyicJpRT+T0E2mQKpu2+xwrUt33DXFBzgFneFP/e4pE6/PoNq3H0SzfoV Y2clElbnAJ3ia3q+TS1h5Cuy9tXmdBwhFGaX18s3YaumLiGyT9A91bFrYSt4jrRNx6IM laj1QbqS3tAwW5LkfZwWNW6Rz5TMtkNaNnrBqEUqChISQH2+ZL8cnOQx2G9sdGKx1BT3 s0ujvXwNcg92+/hYCVqr2zc6Fs9yLER+JyY/+S+HK46LMF8jvOGIEt1rvryr7nVS4ZZx Rg9cg7ewkhazTMvvPzgcOnpz9vx75a0qFcnqHv+ztPhcwierP9Nj1TkXTZytxQ0gKzNy 1QHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753270238; x=1753875038; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nN1qMVzRHpkfA2cRuVdiCu3b2Ziq7OpXFjTGDgHu3zM=; b=dCJG2fFWHvIW4PNzHWLpSGKksdM3S/dmvnDJvlU7U8VpUjyGD1Eu5idEDv8dg8Jk/J WRoq6Y6S1NcOsp5Bb5OVtjeJ4LpNwYcflR6ko89ue4KjLO+Hl8ScOJzRS5e6nMb1tOeq x7fvtgPOI0hWf5U35QM+mOVeqQCmiu6Vm5iQi687J+tRm32CF4gpZfzrRmFDaIsWCV11 3matfXYqGciMvflaNCdLgEwRj+o4G1inrARBhwrmqjkdvgw/Aro6ssDlJLGvw2yRek6/ i+gOxW7smSrg78sAxg9G+AWiSkDOsOTr1Rlc/R4fXRHsbazEExT9MAMNdnGP5WBWQLvy Mnww== X-Gm-Message-State: AOJu0YwMZ/qvWpviIRbbUDcJ+Dx9iaGsJ9ifZiSScdmkZUqA4ZexgJST GWVqpXJqFcJcNCvrc56A+WE9dAN5oFI/XbtH/5ZZwV/Nj8a50mLLalEj38XvH2yMzsp3qAkQtpd yA9+Tt00cohgXQTro/GJT+oh05/GY1QDSgnjaHo4= X-Gm-Gg: ASbGncsWdg14ztkiRSw0kUMFYj0gENTp327VC8a2kPTsEOjEJnqEsTTCmp3sibuDoSL 51Cr+od7Eag2mIKSc99VcHEnZQkL1RBc09T2167CCVWDZ3m5pdAAkK8djS8stT1GqAzrG6VE1Pq X1wjDOK4+tYIt8wOXbNbq2Ew94FgZaiD17G7kT2HxEUQ08qCZTti4IYk/F+vewt7wQlJKtdWq+a KyoHwc= X-Google-Smtp-Source: AGHT+IGQnvjp4O4ZUmw9Nz96eMZSJ+9UstHEUVpXKpRc8QuUiAy7LzI8bjh/V2kvDrdlyZHf5AMcdUM6ja5G0gFnW2U= X-Received: by 2002:a05:622a:4d43:b0:4ab:66c5:b265 with SMTP id d75a77b69052e-4ae6dc8f94emr37720251cf.0.1753270237827; Wed, 23 Jul 2025 04:30:37 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 23 Jul 2025 13:30:26 +0200 X-Gm-Features: Ac12FXzo9kJ2CClFBH_xziW5uDDLREKArCTBnIEDaoLbPRWu3Mg95Wans5gFsCA Message-ID: Subject: Re: [PHP-DEV] [RFC] Warnings for PHP 8.5 To: "Gina P. Banyard" Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000b899a8063a97097b" From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --000000000000b899a8063a97097b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le ven. 18 juil. 2025 =C3=A0 14:54, Gina P. Banyard a = =C3=A9crit : > On Tuesday, 15 July 2025 at 18:16, Nicolas Grekas < > nicolas.grekas+php@gmail.com> wrote: > > Hi Gina, > > Le lun. 14 juil. 2025 =C3=A0 18:22, Gina P. Banyard a > =C3=A9crit : > >> Hello internals, >> >> Similar to the mass deprecation RFC, I would like to propose the additio= n >> of a few warnings in certain situations: >> https://wiki.php.net/rfc/warnings-php-8-5 >> >> I am expecting these 4 sub-proposals to be mostly uncontroversial, >> other than possibly, the "Using offsets on non-container values in >> isset()/empty()" one. >> >> As this is intended to land in PHP 8.5 the discussion will last 2 weeks >> and voting will commence on Monday the 28th of July 2025. > > > Why warnings and not deprecations if the plan is to Error on PHP 9? > As you might know, it's very common to turn warnings into exceptions in > userland so this will break apps for sure. Deprecations don't if properly > handled. Please trigger deprecations instead. > > > Because those point to bugs, rather than usage of a valid feature. > As such a warning is appropriate, and people being made aware more quickl= y > about it by an error handler that promotes warnings is the behaviour I wa= nt. > Then obviously this argument doesn't apply to destructuring non-array values. This makes me doubtful about the others. A deprecation would be more appropriate to me. > About destructuring non-array values, null is a very common case that > allows writing nice readable code. > Here is a dummy example: > if ([$a, $b] =3D $array[$key] ?? null) { /*...*/ } > > Turning this into a warning will have a significant impact for sure. Even > a deprecation would just make the language a bit less pleasant to use > without any real benefit, unless I missed any other rationale. > > > If you want to provide default values, then surely: > > if ([$a, $b] =3D $array[$key] ?? [null, null]) > > makes more sense, especially as this allows you to choice different > defaults for $a and $b. > That's broken, the "if" will always be truthy using this style. There's nothing wrong with the current code. It doesn't need to be deprecated. I'd say the same when false is returned BTW. For other values, I'm not aware of any use cases so might be fine deprecating. Nicolas --000000000000b899a8063a97097b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Le=C2=A0ven. 18= juil. 2025 =C3=A0=C2=A014:54, Gina P. Banyard <internals@gpb.moe> a = =C3=A9crit=C2=A0:
On Tuesda= y, 15 July 2025 at 18:16, Nicolas Grekas <nicolas.grekas+php@gmail.com> = wrote:
Hi Gina,

Le lun. 14 juil. 202= 5 =C3=A0 18:22, Gina P. Banyard <internals@gpb.moe> a =C3=A9crit :
Hello internals,
Similar to the mass deprecation RFC, I would like to propose the addition o= f a few warnings in certain situations:
https://wiki.php.net/rfc/warnings-php-8-5=

I am expecting these 4 sub-proposals to be mostly uncontroversial,
other than possibly, the "Using offsets on non-container values in iss= et()/empty()" one.

As this is intended to land in PHP 8.5 the discussion will last 2 weeks and= voting will commence on Monday the 28th of July 2025.
Why warnings and not deprecations if the plan is to Error on PH= P 9?
As you might know, it's very common to turn warnings int= o exceptions in userland so this will break apps for sure. Deprecations don= 't if properly handled. Please trigger deprecations instead.

Because those point to bugs, rather= than usage of a valid feature.
As such a warning is appropriate,= and people being made aware more quickly about it by an error handler that= promotes warnings is the behaviour I want.
<= div>
Then obviously this argument doesn't apply to=C2=A0d= estructuring non-array values.
This makes me doubtful about the o= thers. A deprecation would be more appropriate to me.
=C2=A0
About destructuring non-array valu= es, null is a very common case that allows writing nice readable code.
Here is a dummy example:
if ([$a, $b] =3D $array[$key] ?? n= ull) { /*...*/ }

Turning this into a warning will = have a significant impact for sure. Even a deprecation would just make the = language a bit less pleasant to use without any real benefit, unless I miss= ed any other rationale.

I= f you want to provide default values, then surely:

if ([$a, $b] =3D $array[$key] ?? [null, null])

makes more sense, especially as this allows you to choice different defau= lts for $a and $b.

That's broken, the "if" will always be truthy using th= is style.
There's nothing wrong with the current code. It doe= sn't need to be deprecated.
I'd say the same when false i= s returned BTW.
For other values, I'm not aware of any use ca= ses so might be fine deprecating.

Nicolas
--000000000000b899a8063a97097b--