Re: [RFC] Safe Casting Functions

From: Date: Wed, 22 Oct 2014 22:24:02 +0000
Subject: Re: [RFC] Safe Casting Functions
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-78256@lists.php.net to get a copy of this message
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

« previous php.internals (#78256) next »