Hi Larry,

Le sam. 2 mai 2026 à 17:47, Larry Garfield <[email protected]> a
écrit :

> 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() <=> ?? equivalence on magic properties, and it'd fixe GH-12695
> > as a
> > corollary. It's forward-compatible as a regular method on PHP <= 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 “uninitialized” (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, and
> 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=diff&rev2%5B0%5D=1777627745&rev2%5B1%5D=1777752909&difftype=sidebyside

y => $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

Reply via email to