Re: [POC - Patch] Scalar Type Hinting - A-La zend_parse_parameters

From: Date: Fri, 09 Mar 2012 06:52:17 +0000
Subject: Re: [POC - Patch] Scalar Type Hinting - A-La zend_parse_parameters
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Anthony Ferrara wrote:
So, what do you think?
I am a big fan of this style. Accepting e.g. "1abc" as int(1) with a notice seems like a better solution than anything else. A full error would be too much towards strict typing (I wouldn't mind personally, but others do have a strong opinion on this, as we've seen). The only thing I'm not so crazy about is foob('abc') -> bool(true). I can live with it, but I don't particularly like it as far as the typing goes. Ilia Alshanetsky wrote:
My concern with this type of patch is that what you are proposing are not really hints, they are forced casts. As such they modify the data potentially leading to data loss.
I disagree with Ilia on this, as the casts are only made if they can be converted properly, and give E_RECOVERABLE_ERROR instead. Anything that's going to have significant data loss is covered by that. Bottom line: I'd personally use this, while I certainly would not use the previous style (with (int) $foo e.g.). -- Ryan McCue <http://ryanmccue.info/>

Thread (46 messages)

« previous php.internals (#58806) next »