Skip to content

Remove unnecessary reference assigment#301

Merged
ezyang merged 2 commits into
ezyang:masterfrom
Axinet:patch-1
Sep 7, 2021
Merged

Remove unnecessary reference assigment#301
ezyang merged 2 commits into
ezyang:masterfrom
Axinet:patch-1

Conversation

@Axinet
Copy link
Copy Markdown
Contributor

@Axinet Axinet commented Sep 4, 2021

Proposed code is PHP5 and PHP7 compatible. PHP5 interpreted $e->$type[$attr] as $e->{$type[$attr]}, but the expected behavior based on workaround is consistent with PHP7 interpretation: ($e->$type)[$attr]. By using curly braces {$e->$type}[$attr] there is a forced interpretation order working for both versions.
Details can be found on https://www.php.net/manual/en/migration70.incompatible.php (section "Changes to the handling of indirect variables, properties, and methods")

Proposed code is PHP5 and PHP7 compatible. PHP5 interpreted `$e->$type[$attr]` as `$e->{$type[$attr]}`, but the expected behavior based on workaround is consistent with PHP7 interpretation: `($e->$type)[$attr]`. By using curly braces `{$e->$type}[$attr]` there is a forced interpretation order working for both versions.
Details can be found on https://www.php.net/manual/en/migration70.incompatible.php (section "Changes to the handling of indirect variables, properties, and methods")
@ezyang
Copy link
Copy Markdown
Owner

ezyang commented Sep 7, 2021

CI no likey

Use correct syntax for indirect variable evaluation order change.
@Axinet
Copy link
Copy Markdown
Contributor Author

Axinet commented Sep 7, 2021

Yeah, sorry, didn't checked exact syntax for that case, the required one is little different than expected.
Its a $foo->$bar['baz']
PHP5 interpetation : $foo->{$bar['baz']}
PHP7 interpetation : $foo->{$bar}['baz'] and this one are needed for all PHP versions, what is achieved with curly braces in place :).

@ezyang ezyang merged commit 996eaf4 into ezyang:master Sep 7, 2021
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.

2 participants