On Sat, 2008-01-05 at 21:35 -0500, Sam Barrow wrote: > On Sat, 2008-01-05 at 15:59 -0800, Mike Lively wrote: > > > Because type hinting is supposed to limit what kind of variable type > > > is > > > allowed for a parameter. When you magically convert you kill the whole > > > idea of type hints and replace it with some magical function parameter > > > auto type conversion, which would be another hard to understand magic > > > feature of PHP. > > > > This is one of the reasons I am not so sure I like the idea of type > > hinting for scalar types. > > > > In a language like php where you often times have data coming in as a > > string no matter what, it seems like strict type hinting would be a pain > > in the neck to use effectively. If you start using 'int' type checks for > > functions you are going to want to be passing data from _GET, _POST, etc > > to, you will have to do is_numeric checks or something similar, so > > instead of saving this userland code (like people are arguing scalar > > type hints will do) you are just moving that userland outside of the > > function into the code calling the function. That doesn't seem like much > > of a win to me in the ease-of-use regard. > > Please, everyone understand this: Type hinting is not intended to be > used for input. Only internal stuff. > > Forget $_REUQEST, $_POST, etc. Type hinting would not be useful for > these things, we all know this.
input is going to makes it's way into your api at some point. Now of course you can (and should) be filtering this input before it is used, but if imo when dealing with a loosely typed language where the same input could be hinted as an int in one function it eventually reaches, and a string in another. The point being I understand you may be targeting 'internal stuff' but programming (especially web development) is centered around manipulating/reading input to perform actions...just because it's not 'intended' doesn't mean it's going to never happen. Also, I am pretty sure PDO returns results from at least mysql and sqlite as strings regardless of their type in the database...or are results from the database also not something type hints are inteded for? -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php