On 04/22/2016 01:03 AM, Benjamin Eberlei wrote:
On Thu, Apr 21, 2016 at 11:13 PM, Dmitry Stogov <dmi...@zend.com
<mailto:dmi...@zend.com>> wrote:
Hi,
I would like to present an RFC proposing support for native
annotation.
The naming, syntax and behavior are mostly influenced by HHVM
Hack, but not exactly the same.
The most interesting difference is an ability to use arbitrary PHP
expressions as attribute values.
These expressions are not evaluated, but stored as Abstract Syntax
Trees, and later may be accessed (node by node) in PHP extensions,
preprocessors and PHP scripts their selves. I think this ability
may be useful for "Design By Contract", other formal verification
systems, Aspect Oriented Programming, etc
https://wiki.php.net/rfc/attributes
Note that this approach is going to be native, in contrast to
doc-comment approach that uses not well defined syntax, and even
not parsed by PHP itself.
Additional ideas, endorsement and criticism are welcome.
I love it!
Syntax is good, and i like that it just returns plain arrays.
Everything else (more formal) can be added on top by Doctrine
Annotations for example.
thanks for support :)
About expressions, isn't there an ambigoutiy? <<test(1)>> is a "plain"
name, value based attribute. But it could also be an ast\node of a
function call to "test(1)"
even in AST scalars are scalars.
so <<test(1+2)>> would return: ast\node "+" with two children int(1) and
int(2).
I am wondering if they shouldn't get their own start/end signs to
clear that up, <<<test(1)>> vs <<test(1)>>.
no need for extra complication.
Thanks. Dmitry.