Hi Dmitry! > 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.
Just a couple of comments on this: 1. I'd definitely reuse the php-ast extension for parsing the code into an AST. It performs a number of transformations on PHP's underlying AST that make it much nicer to use (namely better consistency). It is also less fragile by having the abstraction between PHP's internal AST and the AST that is exposed to userland (enabling for internal AST changes without impacting the AST exposed to userland). 2. You mentioned about moving some of the php-ast extension into core. I wonder if it would be better to just move the whole extension into the core first, and then enable this functionality if the php-ast extension is enabled. Also, slightly tangential, but the RFC says attributes are supported on class constants, yet doc comments (IIRC) are not. I wonder if support for doc comments should be added for class constants? Thanks, Tom -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php