Ron Korving wrote:
If you ask me, scaler type hinting should try to do some auto-conversion. That way, the type hints would actually be useful.
While I like the idea of type hinting on scalars, I agree that it causes issues. Using request data is the main issue. Its all strings.
The only way I see it working is if the hints converted the data and checked if it "changed". So, "1" and 1 are "the same" so it does not complain. Likewise, any number could be changed to a string. But non-numeric strings changing to 0 would throw an error. That is the main place where scalars cause issues.
That does bring up the question of why scalar as a hint is not supported. function test (scalar $var) { echo $var; } I would seem that would have made sense. Currently, that code throws: Fatal error: Argument 1 passed to test() must be an object of class scalar That is funny on its own. -- Brian Moon ------------- http://dealnews.com/ It's good to be cheap =) -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php