Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78256 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17640 invoked from network); 22 Oct 2014 22:24:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Oct 2014 22:24:09 -0000 Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 217.147.176.214 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 217.147.176.214 mail4-2.serversure.net Linux 2.6 Received: from [217.147.176.214] ([217.147.176.214:44110] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 06/79-63701-68E28445 for ; Wed, 22 Oct 2014 18:24:07 -0400 Received: (qmail 6828 invoked by uid 89); 22 Oct 2014 22:24:03 -0000 Received: by simscan 1.3.1 ppid: 6819, pid: 6825, t: 0.2923s scanners: attach: 1.3.1 clamav: 0.96/m:52/d:10677 Received: from unknown (HELO ?10.0.0.8?) (lester@rainbowdigitalmedia.org.uk@86.178.187.131) by mail4.serversure.net with ESMTPA; 22 Oct 2014 22:24:03 -0000 Message-ID: <54482E82.8090709@lsces.co.uk> Date: Wed, 22 Oct 2014 23:24:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 MIME-Version: 1.0 To: internals@lists.php.net References: <66B7B28C-2651-4A71-AC2A-55D4C7BB3DDC@ajf.me> <9cbe0d81ce2ec144a65771d88aa4ca08@mail.gmail.com> In-Reply-To: <9cbe0d81ce2ec144a65771d88aa4ca08@mail.gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Safe Casting Functions From: lester@lsces.co.uk (Lester Caine) On 22/10/14 22:12, Zeev Suraski wrote: > Something like: > > If (!int_convertible($sth)) { // open to new ideas about the name :) > // error out > } > $i = (int) $sth; And this allows each failure with it's own response, while pushing that problem to an exception requires one builds a tree in the exception with responses. There is not a single best case solution but putting the problem this way around looks tidy and keeps processing of each check grouped ... but is probably not how an exception based user would think? Adding additional processing to handle a failed $sth test does not break the work flow! -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk