Repository navigation
fix(php86): report unset, by-reference passing and references of a constant object's property before PHP 8.6 - #14519
Conversation
…nstant object's property before PHP 8.6 vimeo#14500 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Behaviour change
Checked with Verified: |
✅ Performance: unchanged · Types: unchanged
How to read this table
head 60585ea · base c5f4dfd (merge-base) · workflow run |
orklah
left a comment
There was a problem hiding this comment.
Thanks @jirkace! The three cases from #14500 are reported correctly now. A few sibling paths still pass a constant object's property by reference without the check, and PHP 8.5 rejects all of them (Cannot use temporary expression in write context):
<?php
const C = new stdClass();
array_push(C->items, 1); // no issue
array_unshift(C->items, 1); // no issue
array_splice(C->items, 1); // no issue
$r = [&C->items]; // no issuearray_push/array_unshift/array_spliceare handled byArrayFunctionArgumentsAnalyzer::handleAddition()/handleSplice(), andArgumentsAnalyzer::analyze()returns before reaching the loop where the check was added, so their first argument should get the check too;- a by-reference array item (
ArrayAnalyzer, the$item->byRefbranch) should callcheckConstantObjectWrite()on$item->value.
Could you add these, with a test case for array_push and one for [&C->items], both with 'php_version' => '8.5'?
…reference items on a constant object vimeo#14500 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Unsetting, passing by reference or binding a reference to a property of a constant object is not reported before PHP 8.6, although PHP rejects it at compile time.
Before
After
Fixes #14500