Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87296 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51085 invoked from network); 25 Jul 2015 23:29:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jul 2015 23:29:52 -0000 Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 66.111.4.25 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.25 out1-smtp.messagingengine.com Received: from [66.111.4.25] ([66.111.4.25:59506] helo=out1-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/00-50438-FEB14B55 for ; Sat, 25 Jul 2015 19:29:51 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 02C91202AB for ; Sat, 25 Jul 2015 19:29:48 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Sat, 25 Jul 2015 19:29:49 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=wu+WF1VKHN2VVVK ML5nKYngkbGU=; b=biv79YFp+oT+bpkS3FN2Bfv7VJyF9usRetiTBBIrEUS79np bRdNuXS+toR8Krtp/wxW58H3e5TghdClHXr43YEV6A+KaQFB2fts0N5FI/Sraipo LuOR8ZyRB7WTBzTJPT1wGLfm9FKz+o+oql+jRHP0f3fxDs3Ooc6h502EqHjM= X-Sasl-enc: wyLWHXw87dyNDf51vGvcbED+r/dNKziJKA1rT/p6kRcZ 1437866988 Received: from [192.168.42.5] (c-50-129-175-166.hsd1.il.comcast.net [50.129.175.166]) by mail.messagingengine.com (Postfix) with ESMTPA id BEB43680109 for ; Sat, 25 Jul 2015 19:29:48 -0400 (EDT) Message-ID: <55B41BEC.20104@garfieldtech.com> Date: Sat, 25 Jul 2015 18:29:48 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: internals@lists.php.net References: <55A7D993.5000301@moonspot.net> <55B2D142.6020802@gmail.com> In-Reply-To: <55B2D142.6020802@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Core functions throwing exceptions in PHP7 From: larry@garfieldtech.com (Larry Garfield) 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