Skip to content

Fix ?? on property hooks without get-hook invocation (#8902) - #8915

Merged
PurHur merged 2 commits into
masterfrom
agent/issue-8902-property-hook-coalesce
Jun 16, 2026
Merged

Fix ?? on property hooks without get-hook invocation (#8902)#8915
PurHur merged 2 commits into
masterfrom
agent/issue-8902-property-hook-coalesce

Conversation

@PurHur

@PurHur PurHur commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

php-src reference

  • Zend/zend_property_hooks.c — isset/coalesce backing probe
  • Zend/zend_compile.cZEND_AST_COALESCE on hooked properties

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/issue_property_hook_coalesce.php
./vendor/bin/phpunit --filter property_hook_coalesce
./vendor/bin/phpunit --filter property_hook_nullcoalesce_assign
'

Output:

string(1) "a"
ok
string(7) "default"
unset ok
OK (1 test, 1 assertion)  # property_hook_coalesce
OK (1 test, 1 assertion)  # property_hook_nullcoalesce_assign

Closes #8902

Made with Cursor

Zend checks hooked-property backing for ?? / ??= before invoking get hooks.
Wire compiler coalesce lowering and VM backing fetch; resolve php-cfg call-arg
temp clones so var_dump($obj->hook ?? default) uses the coalesce result slot.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep compileCallArgCoalesceSlot before compileHoistedEmptyCallArg.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 3a16754 into master Jun 16, 2026
@PurHur
PurHur deleted the agent/issue-8902-property-hook-coalesce branch June 16, 2026 02:12
PurHur added a commit that referenced this pull request Jun 16, 2026
Regression was fixed in #8915/#8923; unit tests mirror isset/empty hooks coverage.

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Language: ?? on property hooks must not invoke get hook when backing is initialized (zend_property_hooks.c)

1 participant