Fix ??= on property hooks — backing null-check + get/set hooks (#6472) - #6493
Merged
Merged
Conversation
…). Coalesce-assign on hooked properties now tests backing storage for null, reads via get hook on the taken branch, and writes via set hook when assigning. Co-authored-by: Cursor <cursoragent@cursor.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
??=on hooked properties now null-checks backing storage (viapropertyHookRegistryset/get backing fields), not the get-hook return value — matching Zend when backing isnullbut get returns a default.dispatchPropertySetHookAssign).php-src reference
Zend/zend_property_hooks.c— coalesce assign on hooked propertiesPHP implementation
lib/Compiler.php—compileCoalesceproperty fetch read/write branches +issetForCoalesceAssignflaglib/VM.php—objectPropertyIsSetForCoalesceAssign()lib/OpCode.php—issetForCoalesceAssignonTYPE_ISSETCloses #6472
Verification
Issue repro:
Output:
assignedCompliance:
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter property_hook_nullcoalesce_assign test/compliance/VMTest.php'Output:
OK (1 test, 1 assertion)Regression (related coalesce + property hooks):
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter "property_hook_nullcoalesce_assign|property_hook_set_arrow|coalesce_assign|property_hook_unset" test/compliance/VMTest.php'Output:
OK (9 tests, 9 assertions)Made with Cursor