On 07/24/2015 06:58 PM, Stanislav Malyshev wrote:
Hi!
On the surface, this sounds like a good thing. Although, I question that
if a user is not checking $result === false, then will they end up just
wrapping this in an empty try/catch so their code does not fail? There
is a mechanism to detect the error now.
True, but not checking for false is an error of omission, and an easy
one to make ("How can random fail? It's just creating random numbers! I
won't bother to check"),
Another point here is that 0 is a perfectly legitimate random number in
many cases, so callers would need to do a === check, not just a boolean
check. How many people already forget to do that for strpos() on a daily
basis? Too many. :-)
Whatever the exact mechanism, a "break hard so you can't continue"
approach seems far better in this case than a "return false and hope the
user knows what they're doing", even if the latter is currently more
common in PHP itself. Especially as we're talking not about a user
error but a "your system is not setup right so it will never work"
situation, as I understand it.
--Larry Garfield
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php