Skip to content

Conversation

iluuu1994
Copy link
Member

$a->b->c = 'd';

is now compiled the same way as

$b = $a->b;
$b->c = 'd';

That is, we perform a read fetch on $a->b, rather than a write fetch.

This is possible, because PHP 8 removed auto-vivification support for objects, so $a->b->c = 'd' may no longer modify $a->b proper (i.e. not counting interior mutability of the object).

    $a->b->c = 'd';

is now compiled the same way as

    $b = $a->b;
    $b->c = 'd';

That is, we perform a read fetch on $a->b, rather than a write
fetch.

This is possible, because PHP 8 removed auto-vivification support
for objects, so $a->b->c = 'd' may no longer modify $a->b proper
(i.e. not counting interior mutability of the object).

Co-authored-by: Nikita Popov <[email protected]>
@iluuu1994 iluuu1994 force-pushed the nested-fetch-obj-by-read branch from 6541e86 to fc488c6 Compare February 8, 2024 12:12
@iluuu1994
Copy link
Member Author

The fact that the lhs of -> is fetched using W/RW in these given contexts was actually really useful for data classes (#13800). So, I no longer want to make this change.

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