A higher order function (HOF) is a function that follows at least one of the following conditions −
- Takes one or more functions as arguments
- Returns a function as its result
source
And then From the PHP Void RFC:
Since return
; and return null
; are technically equivalent in PHP; when a return value isn't specified, PHP will produce null
for you. However, choosing one over the other suggests intent. If you specify a value, it suggests the value is significant. In a void function, the return value is insignificant: it's always the same and has no actual usefulness. Specifying it explicitly with return null; is pointless, because it doesn't really matter what value the function is going to return.
(My highlights)
Therefore there's simply no need to provide a warning and it would simply require the usage of another function and additional significant compile-time overhead to notify a return error on a piece of code that is deliberately intended not to return.
Think of it like this:
- I will keep lots of sponges on standby just incase the empty milk carton gets knocked over.
The carton will always be empty by intention so there's no need for going down the shop and buying 12 super absorbant sponges!
To view exactly which functions would be called, try exploring the (open source) compile-time error handling logic of PHP 7; to see what functions will be called to process a function that causes a similar error (such as returning an unrecognised or incorrect type).
These functions will be the ones that are not called by silently returning null
instead of an error on PHP 7.1 intended void
return types.