[nycphp-talk] type casting function arguments

Scott Mattocks scott at
Fri Feb 10 15:02:48 EST 2006

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

Nope. Type hints (your first version) don't work on primitives and you 
can't execute commands (your second version) in a function/method 
signature (except setting defaults).

Scott Mattocks

More information about the talk mailing list