18 messages in net.php.lists.internalsRe: [PHP-DEV] [PATCH] Scalar type hin...
FromSent OnAttachments
Hannes MagnussonNov 3, 2006 10:00 am.txt
PierreNov 3, 2006 10:39 am 
Marcus BoergerNov 3, 2006 10:46 am 
Ron KorvingNov 3, 2006 10:48 am 
Ilia AlshanetskyNov 3, 2006 11:06 am 
PierreNov 3, 2006 11:12 am 
Zeev SuraskiNov 3, 2006 12:34 pm 
Brian MoonNov 3, 2006 2:45 pm 
Richard LynchNov 6, 2006 12:18 pm 
Markus FischerNov 6, 2006 11:00 pm 
Richard QuadlingNov 7, 2006 1:26 am 
Ron KorvingNov 7, 2006 2:19 am 
Richard QuadlingNov 7, 2006 2:39 am 
Christian SchneiderNov 7, 2006 6:45 am 
Richard QuadlingNov 7, 2006 7:33 am 
Richard LynchNov 7, 2006 10:45 am 
Richard QuadlingNov 8, 2006 1:37 am 
Derick RethansNov 15, 2006 12:19 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [PHP-DEV] [PATCH] Scalar type hinting ;)Actions...
From:Brian Moon (bri@dealnews.com)
Date:Nov 3, 2006 2:45:26 pm
List:net.php.lists.internals

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.