On Fri, May 13, 2016 at 2:11 PM, Rasmus Schultz <ras...@mindplay.dk> wrote:
> Dear Internals, > > I'm announcing a simplified RFC for annotations: > > https://wiki.php.net/rfc/simple-annotations > > It's an alternative to the proposed Attributes RFC and the (2010) > Annotations RFC. > > I'm attempting with this to describe a feature that is closer to the > language than what is proposed by the Attributes RFC, by permitting > the use of any valid PHP expression as an annotation value. > > Where the Attributes RFC proposes new syntax for what is essentially > arrays, this proposal instead permits you to use actual arrays, e.g. > without inventing any new syntax. It also allows you to use values of > any other type, including objects. This makes the proposed feature > more immediately useful, with a minimal learning curve. > The attributes RFC actually does not specific syntax or arrays, but either a scalar (number, string) or an ast\node. A proposal for arrays *would* actually be "closer to the language" as you describe it. Compared with the old Annotations RFC (and Doctrine Annotations, etc.) > this proposal does not attempt to define or enforce any rules about > what annotations are, permitted usage, inheritance rules, etc. - > instead it adds a very simple language feature upon which the > community may choose to build (and evolve) facilities that implement > additional rules and logic. > > My hope is that, if we can agree on something very small and simple, > we can defer the more opinionated discussions about rules and logic to > the community. > > In my opinion, language features should be simple, and consistent with > the language - I believe the way to do that, is to avoid discussions > about how such as facility should be used, and instead focus on how it > should work. There is a lot of opinion built into the old Annotations > RFC, and into Doctrine - features that attempt to dictate how the > feature should be used. I don't believe the language should dictate > what is or isn't correct or appropriate use. > > Please review and comment. I see you took my question about context from the other thread and defined annotations to be context less. You should add to the RFC examples of what is happening, if you do access context, for example access to undefined variable notices: <<$x>> class Foo {} $refl = new ReflectionClass('Foo'); var_dump($refl->getAttributes(Foo::class)); // PHP Notice: Undefined variable: x in Command line code on line 1 Still this is imho a weak point of your RFC. You already stated that a "simplified annotation" the way you see it is the expression wrapped in a closure: function () { return php-expression; } So if an annotation is a function/closure that belongs to its target (class, property, function, method, ...) then why wouldn't there be a way to specify arguments? The RFC should give an answer to that. The statement you add doesn't make sense without examples. How does dependency injection even work, when you don't have a context? "Annotations that do require context should explicitly ask for that context - for example, you could use an anonymous function, a callable, or an anonymous class, to provide context via dependency injection." greetings Benjamin > Thanks, > Rasmus Schultz > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >