PHP 7 introduces return type declarations. Which means I can now indicate the return value is a certain class, interface, array, callable or one of the newly hintable scalar types, as is possible for …
Tag: return-type
Best practice for PHP methods with regard to reference parameter or explicit return value
I’ve used both methods quite a bit but I recently wondered why I hadn’t standardized on one or the other, or if there was a best practice and what the reasons behind it are. While the returning references page at PHP states quite clearly, with respect to returning references: Only return references when you have a valid technical reason to
Are there more advantages to returning an empty string or null value?
If I were writing the below method (for example) is it considered good practice to either: A: return an empty string if the document didn’t exist? B: return a null value? Having done a lot of Java, and methods in Java requiring a return type, I’m under the impression it is best practice to return a consistent type, is this