Re: Scalar-type-hinting - which way is the best to go?

From: Date: Mon, 19 Mar 2012 04:17:37 +0000
Subject: Re: Scalar-type-hinting - which way is the best to go?
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-59025@lists.php.net to get a copy of this message
On Sun, Mar 18, 2012 at 7:11 PM, Simon Schick <simonsimcity@googlemail.com>wrote: > Hi, Adam > > I totally agree that type-hinting should not cover what the programmer > should do for validating the given input ... > But I just wanted to point out that this is something the author (and > I) would never expect to happen ... > > in_array("123abc", array(3, 7, 123, 28)) === true > Hi Simon, That's how we differ in terms of perspective. When I see that in_array() accepts a third argument $strict and that $strict defaults to false, in_array("123abc", array(3, 7, 123)) === true is the behavior I expect for that function: http://php.net/manual/en/function.in-array.php That said, perhaps the documentation could be augmented to help clarify the issue. While example 2 on that page illustrates a non-match using the strict check, it does seem like showing the opposite (a surprising match when $strict is false, such as in the example your link pointed to) would also prove beneficial to users, too. Nice commentary. Adam

« previous php.internals (#59025) next »