Skip to content

Add support for __exists(), a magic method for distinguishing "missing" from "set to null"#22240

Open
nicolas-grekas wants to merge 2 commits into
php:masterfrom
nicolas-grekas:exists-magic
Open

Add support for __exists(), a magic method for distinguishing "missing" from "set to null"#22240
nicolas-grekas wants to merge 2 commits into
php:masterfrom
nicolas-grekas:exists-magic

Conversation

@nicolas-grekas
Copy link
Copy Markdown
Contributor

See draft RFC at https://wiki.php.net/rfc/exists-magic-method

This PR is based on top of #22181 (a small engine fix for GH-12695, decoupled from this RFC and proposed for merge separately). The first commit in this PR is that fix.

After __isset() returns true under ?? or empty(), re-check the
property table before calling __get(). When __isset() materialised
the property (a pattern used by lazy proxies), its value is returned
directly. isset() itself is unchanged.

Closes phpGH-12695.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant