On Tue, Feb 17, 2015 at 10:13 PM, Alexander Lisachenko < lisachenko...@gmail.com> wrote:
> > 2015-02-17 19:25 GMT+03:00 Dmitry Stogov <dmi...@zend.com>: > >> I think yes, >> However, Alexander thinks differently >> https://wiki.php.net/rfc/parser-extension-api >> Of course this is not for 7.0 >> > > This RFC consists of two parts: parsing API and parser extension API. Last > one can be rejected, however it can be perfectly connected with annotation > RFC (if AST will be used as values) > firs part may be accepted. The second can't be accepted for 7.0 just because of time limit. (we have feature freeze in a month) > As for annotations, general use-case is appreciated. This can be extended > later in future versions of PHP. Therefore, annotation syntax should allow > to define key and values. Value can be valid expression (AST? concrete > node? compiled value?) or can recursively contain nested annotations. > Annotaion syntax: <key(php-expression-value)> "php-expression-value" is parsed by standard PHP parser into AST. This AST is stored in annotations table at slot "key". Constant expressions are evaluated at compile-time and we store only the resulting constant value. Then it's possible to retrieve this AST (or value) using Reflection API. ReflectionMethod->getAnnotations(); ReflectionMethod->hasAnnotation(string $key); ReflectionMethod->getAnnotation(string $key); Then it's possible to traverse AST using some API like https://github.com/nikic/php-ast It also should be possible to evaluate retrieved "php-expression-value" in some context and reconstruct PHP source for any AST node. Thanks. Dmitry.