Re: On how a little knowledge is completely useless.
| From: | Stas Malyshev | Date: | Fri, 17 Sep 2010 17:49:49 +0000 |
| Subject: | Re: On how a little knowledge is completely useless. | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-49757@lists.php.net to get a copy of this message | ||
Hi!
Unless the PHP parser engine can be extended via normal or zend extensions, no, it can't. And pretty useless to have annotations outside the core...I disagree - it would be very useful *if* we could do that. I.e. if we could associate data with classes, functions, etc. without actually changing the code. Unfortunately, we don't have it yet. Some languages - like Python - have those as first-class objects, so you can just put stuff there. We don't have it, though we have Reflection - so we might use it instead. Then, the question of syntax arises. Basically, if we had method in ReflectionClass like this: static function addAnnotation($class, Annotation $a) { self::$annotations[$class][] = $a; } and we could have some useful syntax to call it implicitly - say, on class creation - that would be it. However, we have here two problems that we can't solve yet: 1) extending Reflection (maybe can be done in userspace) 2) adding syntax (probably can't be done in userspace unless somebody thinks of a clever way to do it). -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227