Re: RE: Optional scalar type hinting

From: Date: Thu, 03 Jan 2008 21:59:10 +0000
Subject: Re: RE: Optional scalar type hinting
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-34362@lists.php.net to get a copy of this message
> So now to use such function you'd have to check your variables for > typing - otherwise your application blows up. And the type-checking > should be total - otherwise you miss some call to some function or some > code path bringing wrong value and your application blows up at runtime > - since static type checking is not available. Unless you are aware of the type of your variables and the data they contain as you write your applications, you are only inviting trouble anyway. Yes, PHP handles type juggling on its own but it is not magic wand that makes caring for the data type of your variables meaningless. > Meaning, unless all of > your code is type-enforced, you'd have to write a wrapper around each > type-enforced function manually checking that wrong value didn't get in. > But you can do the same checks now, so what is the added value? The one I mentioned not so long ago, or we you not paying attention? Having the type hinted on the function declaration saves me the time and energy of checking the type myself, which is something I have to do quite often. It, of course not, remove the need to validate your arguments completely. But it would be a big help. Tomi Kaistila PHP Developer

« previous php.internals (#34362) next »