RE: [PHP-DEV] Re: Re: PHP Annotations RFC + Patch
| From: | Jonathan Bond-Caron | Date: | Tue, 14 Sep 2010 18:30:01 +0000 |
| Subject: | RE: [PHP-DEV] Re: Re: PHP Annotations RFC + Patch | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-49646@lists.php.net to get a copy of this message | ||
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);
}
}