Dear internals,
Following the discussion around the __exists() RFC, PR #22181 [1] isolates the engine-only piece that was suggested there. The broader __exists() proposal remains on the table separately; this PR is scoped to just the sequencing issue.
When ?? or empty() triggers __isset() on a magic property and __isset() writes into the property table (a pattern used in userland to lazily initialise a property), the engine currently calls __get() afterwards anyway. That redundant __get() is mostly cosmetic, but it can trip up patterns where __get() routes through a parent that doesn’t know about the just-materialised property.
The patch adds a property-table re-check after __isset() returns true: if the property now exists physically, the value is returned directly and __get() is skipped. isset() itself is unchanged (it
has never called __get()).
This sits between bug-fix and feature, so per the usual process: planning to merge to master in two weeks unless there are objections.
The PR has already been reviewed by @iluuu1994 and @arnaud-lb.
[1] https://github.com/php/php-src/pull/22181
[2] https://github.com/php/php-src/issues/12695
Cheers,
Nicolas