-
Notifications
You must be signed in to change notification settings - Fork 166
Enhancement: Improve legibility of ScopeManager #35
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
Conversation
src/DDTrace/ScopeManager.php
Outdated
| } | ||
|
|
||
| return $this->scopes[count($this->scopes) - 1]; | ||
| return end($this->scopes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently, we are interested in returning the last element, so maybe end() is better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
end() modifies the array's internal pointer, which may or may not surprise us somewhere else. I don't think the original line is unclear.
| public function deactivate(Scope $scope) | ||
| { | ||
| $scopeLength = count($this->scopes); | ||
| $i = array_search($scope, $this->scopes, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use array_search() to find the index of $scope in $this->scopes, maybe better than looping?
chuck
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The array_search() works, but I don't think the end() one is a good idea.
src/DDTrace/ScopeManager.php
Outdated
| } | ||
|
|
||
| return $this->scopes[count($this->scopes) - 1]; | ||
| return end($this->scopes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
end() modifies the array's internal pointer, which may or may not surprise us somewhere else. I don't think the original line is unclear.
657b38c to
a968547
Compare
|
@localheinz Can you update based on feedback, or should I work off of your branch? |
|
Already amended a couple days ago - does this work? Please let me know if you prefer me to apply more changes. 🤓 |
|
Sorry, missed the update. Thanks! |
|
Thank you, @chuck! |
This PR
ScopeManagera bit