Re: Re: Flexible type hinting
| From: | Richard Quadling | Date: | Fri, 03 Jul 2009 09:51:59 +0000 |
| Subject: | Re: Re: Flexible type hinting | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-44676@lists.php.net to get a copy of this message | ||
2009/7/2 Stanislav Malyshev <stas@zend.com>:
> Hi!
>
>> function func(int $i)
>>
>> for strict type checking, and
>>
>> function func((int)$i)
>
> Without saying anything on the merits of having both syntaxes, visually I
> think this looks much nicer, even with the disadvantage of parentheses
> overload.
Oh look, auto-casting. And __cast() is excellent, but would be at odds
with __toString().
And then having __toBoolean(), __toInteger(), etc. might be a bit OTT.
How about __cast($type [,$class]) where $type is one of the T_xxx_CAST
constants and class is the required class for a class casting? (See
nearly already there!)
T_ARRAY_CAST
T_BOOL_CAST
T_DOUBLE_CAST
T_INT_CAST
T_OBJECT_CAST
T_STRING_CAST
--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
I need a car : http://snipurl.com/l4pih
ZOPA : http://uk.zopa.com/member/RQuadling