Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add back @return $this annotations #42714

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

Merged
merged 1 commit into from
Aug 25, 2021
Merged

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Aug 24, 2021

Q A
Branch? 6.0
Bug fix? no
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

In #42213 I removed those annotations and tried to convinced myself and others that we could do so without loosing too much.

I was about to send a PR to remove all remaining similar annotations. When I reviewed the patch I created for that, I stopped on ItemInterface::tag() (which is just an example):

* @return $this
*
* @throws InvalidArgumentException When $tag is not valid
* @throws CacheException When the item comes from a pool that is not tag-aware
*/
public function tag(string|iterable $tags): static;

If we remove that annotation on the interface, all implementations will have to deal with the return value of the call to tag(). Whereas with @return $this, the contracts are clear: no need to, implementations are expected to mutate and return the current object. I don't think this would be appropriate in this example.

/cc @nikic as this might be some nice food for thoughts to consider adding $this as a possible native return type.

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.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.