Re: [RFC] Safe Casting Functions
| From: | Rowan Collins | Date: | Tue, 21 Oct 2014 20:56:54 +0000 |
| Subject: | Re: [RFC] Safe Casting Functions | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78211@lists.php.net to get a copy of this message | ||
On 21/10/2014 02:48, Stas Malyshev wrote:
I think the point was that ext/filter extension is optional (its enabled by default, but not mandatory) whereasIt would be possible to make to_int() merely an alias offilter_var(…, FILTER_VALIDATE_INT). Though that would make it depend on ext/filter or otherwise duplicate functionality. You seem to sound like depending on something already existing in PHP is a bad thing.
I'm not sure how using function starting with to_ is "more straightforward" than using function starting with filter_As I mentioned in a previous thread, the design of ext/filter makes it feel like a Swiss Army knife when what I'm looking for is a pair of scissors - it will work, but I have to figure out how to select the right component (both a function and a filter type), and whether the other bits will get in my way (do I need to set any options? what is the actual return type?). On the other hand, the myriad of options it provides covers off most of the issues in this discussion, so maybe that complexity is the price you pay for pleasing all the people, and it's just a matter of documentation. -- Rowan Collins [IMSoP]