Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130749 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 41F701A00BD for ; Sat, 2 May 2026 20:17:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1777753072; bh=xzXijC4LsBUKSLOLNErrDmdb4hyNFPhAJNCwxdlYRHM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=AvPu72yuu0hmMnVZ4U78GCGAPuRJkA4/3/KZ+pnt6cfhbpufN1rIJgjPTWxQjvULy KJyxqYsIH//uALJrH7zJ7pm3kIhIo3xeXOjDTP4lbQXyncEh85EcTA0SZwcEhw1U4w ILPYIzMtgzyh4+Wzm/1SjpbbO+C7xlbq59R9BbXBvm7anUBs0nTzf+UN61v6lmn9fk hRCC5rM1ZFyvJNmZBPCaMlP8ajf/wHsDAw/eN4AL7PVxkIWbVOG1YZ03BaX2F4Ghm6 fg7/93W4het2OveIFeifw+ktfVmwGxm1Iv+cJsZSaWIyVZfpYIsLbJA2EtvRql7DXk J/vJb/m9JenAA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 434681801D9 for ; Sat, 2 May 2026 20:17:50 +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,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (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 ; Sat, 2 May 2026 20:17:47 +0000 (UTC) Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-8d4f78fc9f6so321591085a.3 for ; Sat, 02 May 2026 13:17:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777753062; cv=none; d=google.com; s=arc-20240605; b=cok+9O2dnx7tEBXNjWJMdRVwtxQis7ZAvXSq2FioJLdNUvcBHsCLfzgXtoaBQPWl8h hAwGvU2mswA0OiYThpuj/R94u0FEQl4B8I7IoXu6+isAbaHgUjeYHSrbWnXqVNGelk+S aM8yJzLJp/UlrnEOH8KRVDB8GJNE07J4tdDw+elQUbQnsEWba0WXyTKF9hc+PeaRh7IL hsNZtd4BGUizLPJWYgHhko/O8DukFE8rip/2yB+K5KCLjRrcS0BPhRW/1e30ZehrqUeM DILNgi92cXlTvAMy6/SiwyFYjXFuKQTnPJxXetx/LnVhD3PVs9AkQo1Nnh3oXYpBvu63 uAtA== 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=CVhmdcHLz0MG+xR7PeJ/6tajyDyYTIVQOxLuYkDO3Tw=; fh=Ofn+XpSLefQyxrNYeqFK5V6BgIEzMTvoqvpJ6/SQfuk=; b=hY/prDhl9ZRKyZvXe/AKfQjrV4nHVzZD3g3+h+/HcZKoywQe+RSglDfEmfUDlaCgvL C0PjI3hYUG8Ao5i+Y3CXM5d9/tD48O3cngnAiUdMM+9QzEgSdqLQy0XimPfH1m3q2pcW 8D1ZgNy1nvybhNfO1Z1TWPJNzMNDjKnlu73FeAmgIFAoikq7PsAOuyzcPffh0Z/F3F8u OGbTD7xgHKQ79kfnXwi2shzhd93JB1uibJMPNIKajLOG1fyWcKBaOaBSlbVfZ64AL5vJ EC+5CRX7C8zkSuuKPiiQfyPregOIMnNM15VbfvGSZLFsVjkL7bztCm/GJV79Y+AGR03O Rs9w==; 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=20251104; t=1777753062; x=1778357862; 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=CVhmdcHLz0MG+xR7PeJ/6tajyDyYTIVQOxLuYkDO3Tw=; b=qOmYnb9bqghcos0ENKwrmU0+7osfezzU5D/zCgMfZA4dSnO1MzQAfAaAfCGxdJrc+t 4UEHvRNECvzQgCU5s3VunlPS2zJf8RVs9R39x4jLV14We0I075UAYBnHijd+YnGTW0Il d0IRfKGM5AeWBCCay3TCo9/1s/A4eTvjKsSAySf18q8m0oWUTm6e1i0la7O1qjgZhvyS wLNRejZKB3SlWNkOTzYyYOI18409DD6bJRlzLFz/rD9iIWYMbTGAAAQQ1ehqg/s4ayoy erUdijeStv7SNzDFwupcQvEEaK5akY9prV08DS0jtlrr12ONOpIy9NAw1K8NUySzieY9 JMAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777753062; x=1778357862; 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=CVhmdcHLz0MG+xR7PeJ/6tajyDyYTIVQOxLuYkDO3Tw=; b=D8Oa7yjNXNadxefAyzEgvrgR2XgfeVIXwrGoQdh3cS42GMrD1MAcXeOmZEWt/IJoM5 jdzl5ec0J13QFg8Y0FhXz0TK2OfX7iC+0jOOTMVnCr1I+WkuB/OJukm5UHvyf+J1UIpr sHF0PF8vz99C6VL1RnWKRgt/WEpKWXdtuuCz52BfMDHUu+X1g1HTwwyBC+X8fRIwhpdR 6p93Gao5rPgwbdTh2kcouc9f85tQYKCjDuYYxiHinNqfQayoWykykFCR0HffjxMNh3hE hUdNsudg0j4BJm/HlgH5zcqU2LpBRFQ3zOZZuAJOftcsEGqL6OtC9DE50ZVaIcENOjU+ UxSw== X-Gm-Message-State: AOJu0YyqZgSM3V2FhpLVE1AeTnzZboSP4wHwga0XP6kBn4CA5ga4KsfB /hN+q3uN7E0ixTETw0e3NboBk6hZfP0agjbabittXp4UQC5Rvu/lxAcTV7cGdizdDxqNHTUyCC/ G3X5gsSRGS/i3je4fZwqC+kEPhgG5DWm6UfgalCo= X-Gm-Gg: AeBDievLR66RUkTytnykXaAV0abVrw6EQqI3t4zbr7r+gsbVV8diLBgL/Rl4EVESXzV p6Zj50jbz/d3L/k3htOVYUSrfdM0WEn48xEISK7ZcJnZdhzIqKZFt++ZSk92sdpJhd76IBgS8dp ND9An0f8CueVXC4wyZRYV8Uj1SMhEFHIixRN3zjNOtOfXHTZ/VTlvefMsKNNuttSA2O2cxwQ9VW mwieC/8TKojtdVnlKAm2S+GxBhKK6RW6HeqJryqzuu8Ntr/JGFRm0hoE225g7gVR7uEiP11b3vx nWJe93k6pdToJ2Nv0vsLbtJLLHZHcsJ8E3iULQaM0oXuj4jMIIDE33CISRSF6LSDXDBd95Mk5EP d5K/eSz5A5MoR49UdNaQ6qJ/FSahutcI7hh6CjWopXW72vpdQnVCGXy58M2P5+T/xmd6ClP1BR6 cknEkJ03WFXN2U/sdKrhUsjsQixFgfi8FWGeaw X-Received: by 2002:a05:620a:4496:b0:8d7:cf69:3bf5 with SMTP id af79cd13be357-8fd15cdaf6fmr679442985a.14.1777753062014; Sat, 02 May 2026 13:17:42 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <524d2690-f231-4612-a4a3-2db1bb4158c8@app.fastmail.com> In-Reply-To: <524d2690-f231-4612-a4a3-2db1bb4158c8@app.fastmail.com> Date: Sat, 2 May 2026 22:17:31 +0200 X-Gm-Features: AVHnY4LY3T-LquLEaxHmNmMsGqaCWwsgY5xQRdnOdnkPQUy7zBbbH4nAQ3fyR5k Message-ID: Subject: Re: [PHP-DEV] [RFC] __exists(), a magic method for distinguishing "missing" from "set to null" To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000c2838e0650db6316" From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --000000000000c2838e0650db6316 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Larry, Le sam. 2 mai 2026 =C3=A0 17:47, Larry Garfield a =C3=A9crit : > On Fri, May 1, 2026, at 4:37 AM, Nicolas Grekas wrote: > > Dear internals, > > > > It's my pleasure to submit this new RFC to yours. > > Please have a look and let me know: > > https://wiki.php.net/rfc/exists-magic-method > > > > TL;DR: I'm proposing a new opt-in magic method: > > > > public function __exists(string $name): bool; > > > > It'd let userland tell "set to null" apart from "missing" on objects, > > it'd restore > > isset() <=3D> ?? equivalence on magic properties, and it'd fixe GH-1269= 5 > > as a > > corollary. It's forward-compatible as a regular method on PHP <=3D 8.5 > > (probeable > > via method_exists()), and would be magic on 8.6+. > > > > Cheers, > > Nicolas > > Thanks for the very detailed RFC! > > > If it returns false, the fetch produces =E2=80=9Cuninitialized=E2=80=9D= (treated as null > by ??, so y is evaluated). __get() is not called. > > What is y? Looks like a reference to a previous iteration of the text. > > The Sequencing section also doesn't describe the behavior when __exists() > isn't defined. Does it just skip to step 4? (Please specify in the text= .) > > Is the intent to eventually deprecate __isset()? The RFC it doesn't now, > but do you feel that is the eventual end-game, in PHP 10 or whatever? > > The big one: Should any parallel changes or additions be made to property > hooks? An exists() operation in addition to get/set, for instance? (I'm > not sure at the moment, but it should be thought through and discussed, a= nd > if not, documented in the RFC.) Thanks for having a look! I made some changes to clarify, see: https://wiki.php.net/rfc/exists-magic-method?do=3Ddiff&rev2%5B0%5D=3D177762= 7745&rev2%5B1%5D=3D1777752909&difftype=3Dsidebyside y =3D> $y I added a description of the current sequencing of magic methods. About deprecating __isset, I think it's way too early to consider doing it for real. Still my answer is yes, but not on any timescale I can anticipate. I added words about the doc, which should now encourage __exists IMHO. About hooks, that deserves a separate RFC to me. I've no intuition on this as I don't use hooks often enough to feel the need for any missing "exists" hook. If you still want my noob take on this: a hooked property exists - because it has hooks. Not super helpful :D I added some words about this in the RFC. Cheers, Nicolas --000000000000c2838e0650db6316 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Larry,

Le=C2=A0sa= m. 2 mai 2026 =C3=A0=C2=A017:47, Larry Garfield <larry@garfieldtech.com> a =C3=A9crit=C2=A0:
On Fri, May 1, 2026, = at 4:37 AM, Nicolas Grekas wrote:
> Dear internals,
>
> It's my pleasure to submit this new RFC to yours.
> Please have a look and let me know:
> https://wiki.php.net/rfc/exists-magic-method >
> TL;DR: I'm proposing a new opt-in magic method:
>
>=C2=A0 =C2=A0 =C2=A0public function __exists(string $name): bool;
>
> It'd let userland tell "set to null" apart from "mi= ssing" on objects,
> it'd restore
> isset() <=3D> ?? equivalence on magic properties, and it'd f= ixe GH-12695
> as a
> corollary. It's forward-compatible as a regular method on PHP <= =3D 8.5
> (probeable
> via method_exists()), and would be magic on 8.6+.
>
> Cheers,
> Nicolas

Thanks for the very detailed RFC!

> If it returns false, the fetch produces =E2=80=9Cuninitialized=E2=80= =9D (treated as null by ??, so y is evaluated). __get() is not called.

What is y?=C2=A0 Looks like a reference to a previous iteration of the text= .

The Sequencing section also doesn't describe the behavior when __exists= () isn't defined.=C2=A0 Does it just skip to step 4?=C2=A0 (Please spec= ify in the text.)

Is the intent to eventually deprecate __isset()?=C2=A0 The RFC it doesn'= ;t now, but do you feel that is the eventual end-game, in PHP 10 or whateve= r?

The big one: Should any parallel changes or additions be made to property h= ooks?=C2=A0 An exists() operation in addition to get/set, for instance?=C2= =A0 (I'm not sure at the moment, but it should be thought through and d= iscussed, and if not, documented in the RFC.)

=C2=A0Thanks for having a look!

I made some cha= nges to clarify, see:

y =3D> $y
I= added a description of the current sequencing of magic methods.
= About deprecating __isset, I think it's way too early to consider doing= it for real. Still my answer=C2=A0is yes, but not on any timescale I can a= nticipate. I added words about the doc, which should now encourage __exists= IMHO.
About hooks, that deserves a separate RFC to me. I've = no intuition on this as I don't use hooks often enough to feel the need= for any missing "exists" hook. If you still want my noob take on= this: a hooked property exists - because it has hooks. Not super helpful := D I added some words about this in the RFC.

Cheers= ,
Nicolas
--000000000000c2838e0650db6316--