Re: Type hinting - Request for Discussion

From: Date: Fri, 10 Jul 2009 10:35:45 +0000
Subject: Re: Type hinting - Request for Discussion
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-44895@lists.php.net to get a copy of this message
On 7/10/2009 13:23, Giovanni Giacobbi wrote:
On Fri, Jul 10, 2009 at 02:44:52AM +0200, troels knak-nielsen wrote: [...]
For example, instead of:
     function addFive(int $x) {
       return $x + 5;
     }
You would simply do:
     function addFive(is_numeric $x) {
       return $x + 5;
     }
Since $x is guaranteed to be numeric, it is safe to to arithmetic on it. No reason to explicitly type cast here.
     I like it too. Not only it solves the initial problem, but it also allows userland extensions. For example,
the current patch does not provide checks for callables, but we already have is_callable in the core. -- Ionut G. Stan I'm under construction | http://igstan.blogspot.com/

« previous php.internals (#44895) next »