Re: [RFC] PHP Attributes

From: Date: Fri, 22 Apr 2016 09:04:42 +0000
Subject: Re: [RFC] PHP Attributes
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-92632@lists.php.net to get a copy of this message
On 22/04/2016 08:17, Dmitry Stogov wrote:
On 04/22/2016 05:15 AM, Sara Golemon wrote:
On Thu, Apr 21, 2016 at 2:13 PM, Dmitry Stogov <dmitry@zend.com> wrote:
I would like to present an RFC proposing support for native annotation.
I'm trying to imagine where the benefit of non-constant expressions comes in. <<foo($a < 1)>> Assuming we roll in php-ast at the same time (which is a big addition, IMO, and deserves its own separate RFC), what are users meant to do with this? Even if there's a use-case here, one could accomplish the same thing with: <<foo('$a < 1')>> And manually running that string into php-ast if that's what the caller wanted.
Good point. It's really not a big deal to run ast\parse_code($r->getAttributes()["foo"]) This would simplify the implementation a bit.
I can't speak for the implementation details, but I see a few benefits of having real AST vs a string.. You get syntax highlighting in editors, and most importantly compile time syntax errors if you messed up. Cheers -- Jordi Boggiano @seldaek - http://seld.be

« previous php.internals (#92632) next »