[nycphp-talk] type casting function arguments

Andrew Yochum andrew at
Fri Feb 10 15:03:12 EST 2006

On Fri, Feb 10, 2006 at 02:49:52PM -0500, Cliff Hirsch wrote:
> Is there any way to typecast a function argument like:
> public function Partytime(int $argument)         // this actually
> expects an object of class int
> or 
> public function Partytime( (int)$argument)      // this barfs

No.  What you're trying to do is type hinting, which only works for the
compound types: classes (as of 5) and arrays (as of 5.1). See:

Maybe someday the other (scalar) primitives will make it in there.

Andrew Yochum
andrew at

More information about the talk mailing list