php-imap
php-imap copied to clipboard
Fix: Improve return type hints and return docblocks for query classes
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 the WhereQuery 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; hence static 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