Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove many remaining uses of references #668

Merged
merged 1 commit into from
Mar 15, 2019

Conversation

hemberger
Copy link
Member

See #317.

This handles three major remaining usages:

  • When returning objects or arrays from class methods.
    Objects should almost always be returned "by value" (since they
    are handled internally as references by PHP). Arrays should be
    returned "by value" except, perhaps, if they will be modified.

  • In foreach loops. The only time a reference is needed here is
    when you want to loop over an array and modify array elements.

  • In template includes. We never want to modify variables within
    templates, so there is no reason to use references here.

See smrealms#317.

This handles three major remaining usages:

* When returning objects or arrays from class methods.
  Objects should almost always be returned "by value" (since they
  are handled internally as references by PHP). Arrays should be
  returned "by value" except, perhaps, if they will be modified.

* In foreach loops. The only time a reference is needed here is
  when you want to loop over an array and modify array elements.

* In template includes. We never want to modify variables within
  templates, so there is no reason to use references here.
@hemberger hemberger merged commit 5a4233d into smrealms:master Mar 15, 2019
@hemberger hemberger deleted the remove-references branch March 15, 2019 23:05
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.

1 participant