Skip to content

Conversation

@localheinz
Copy link
Contributor

This PR

  • improves the legibility of the ScopeManager a bit

}

return $this->scopes[count($this->scopes) - 1];
return end($this->scopes);
Copy link
Contributor Author

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?

Copy link
Contributor

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);
Copy link
Contributor Author

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?

Copy link
Contributor

@chuck chuck left a 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.

}

return $this->scopes[count($this->scopes) - 1];
return end($this->scopes);
Copy link
Contributor

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.

@localheinz localheinz force-pushed the feature/scope-manager branch from 657b38c to a968547 Compare July 12, 2018 21:00
@chuck
Copy link
Contributor

chuck commented Jul 24, 2018

@localheinz Can you update based on feedback, or should I work off of your branch?

@localheinz
Copy link
Contributor Author

@chuck

Already amended a couple days ago - does this work? Please let me know if you prefer me to apply more changes.

🤓

@chuck
Copy link
Contributor

chuck commented Jul 25, 2018

Sorry, missed the update. Thanks!

@chuck chuck merged commit bfc225d into DataDog:master Jul 25, 2018
@localheinz localheinz deleted the feature/scope-manager branch July 25, 2018 15:52
@localheinz
Copy link
Contributor Author

Thank you, @chuck!

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