I will again turn to SOLID principles starting with the release of PHP 7. In particular, the idea of the Liskov signature principle , which in a nutshell says that any extension of the class should be available anywhere in its parent class can be used.
Part of this principle is interface coding, so your methods define contracts for adhear. However, in PHP 5 and below, return types do not exist. Therefore, although you should have the same parameter types passed to methods using interfaces, you can return any old type that you like. Thanks to large projects, this makes this principle much more complicated than other languages.
I do not have PHP 7 that has just been installed to test this, and I have not seen any documentation in the PHP manual or on any blogs that use the new features.
Are return types with interfaces possible in PHP 7?
source
share