Add back @return $this annotations
#42714
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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):symfony/src/Symfony/Contracts/Cache/ItemInterface.php
Lines 52 to 57 in 444d43f
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
$thisas a possible native return type.