Fix: Improve return type hints and return docblocks for query classes #470
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.
First of, thank you for this package! Its a great library that has had a great and positive impact on our work.
While using this package I found that the type-hinting for some of the methods wasn't optimal. This meant that using functions such as
fetchOrderDesc
meant you could no longer receive type hints for theWhereQuery
methods.I have implemented two changes in this PR:
Firstly, I have re-typed all function return type hints to
static
. This is more truthful than saying it returns itself -- if you were to extend these classes (such as the WhereQuery does the Query) then the reality is that it will return the subclass when these methods are called; hencestatic
as its context aware.Secondly, I have changed all the return docblocks to
@return $this
where they were previously set otherwise. Most of the functions followed this pattern anyway, but there were a couple that seemed to be forgotten about.Functionally, nothing has changed - but it allows editors to decipher and understand what is happening more easily.
If you'd prefer to not change the return type hints and only do this through the docblocks, I am happy to revert the change to the return type hints.
Many thanks,
Ollie Scase
~ techlove