Re: Re: Type hints revisited [IllegalArgumentException instead of E_ERROR]

From: Date: Mon, 31 Mar 2003 13:06:42 +0000
Subject: Re: Re: Type hints revisited [IllegalArgumentException instead of E_ERROR]
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-537@lists.php.net to get a copy of this message
At 15:55 31/03/2003, Wez Furlong wrote:
You can use function_exists() to avoid a fatal error, but there is no equivalent function_parameters_are_ok() API to avoid a miserable death in the situations that I have already mentioned. Why not just be consistent with all the other parameter checks and raise an E_WARNING and RETURN_NULL when the parameters are incorrect? I don't see what is so special about hinted parameters that they have to bail out the engine, while the built-in (and extension) functions will happily return NULL and continue execution.
I see a huge difference. First off, most functions don't return NULL or even bail out at all, they just convert their argument as necessary and try to make do. Secondly, I see a big difference between built-in functions and userland functions. With userland functions, I think there's a very high WTF factor for them returning without actually running their code. I don't think that this WTF factor exists for built-in functions, as they are perceived as black-boxes. Returning NULL works well in case your function has a meaningful return value, such a result set, SQL link, a string or what not. It's not that useful when your function is returning nothing, or when it has a return value that's not likely to be checked. Zeev

« previous php.internals (#537) next »