On Tue Sep 14 01:25 PM, Nate Abele wrote:
> 
> Sorry, but I don't see how this is even remotely close to being 
> appropriate for PHP. Maybe I'm missing something. :-)
> 

I agree, the use cases are just not there

Though maybe some form of "annotations" could be useful in php as a
"pluggable type":
http://bartoszmilewski.wordpress.com/2009/01/18/java-pluggable-types/

But this isn't an annotation as just plain metadata, the parser could do
something with the annotation.

i.e.

class Phone {

   @ReadOnly
   public $id;

   @PhoneNumber
   public $number;
}

class PhoneNumber implements TypeAnnotation {

   static function getTypeValue($val)
   {
      return preg_replace('~[^0-9]~', '', $val);
   }
}

Instead of ~

class Phone {

   protected $_number;

   function __get($prop) {
     if($prop === 'number')
       return $this->_number;
   }
 
   function __set($prop, $val) {
     if($prop === 'number')
       $this->_number = preg_replace('~[^0-9]~', '', $val);
   }
}


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to