But, in my opinion at least, parsing docblocks also brings in a new
syntax. The only difference that I see is that parsing docblocks is
wrapped in a comment and not syntax highlighted by most editors.

Just out of curiosity, how did traits make it into 5.4 if we are
avoiding syntax changes? You could use the same argument for traits:
they introduce new syntax and advanced users can make do by copying and
pasting. You could make the same argument for many features.

You seem to have a issue with introducing new syntax. How would you feel
if the syntax was very similar? Would you say that the "price" of this
feature would be much lower and possibly even worth it. Maybe the syntax
would look something like this:

attribute RestMethod('/do/something', 'Do Stuff', 'Does something.', array(
'arg1' => 'A cool argument!'
public static DoSomething($arg1) {


attribute Example('arg', 'arg2', 3, (time() > 0 ? true : false));
class Demo {

That way it is clear that that line is an attribute. If the person
doesn't know what an "attribute in PHP" is, they can Google it.

This does the following:
- No new branch of syntax is introduced like C# style annotations or
parsed docblocks would. The syntax is very similar to standard PHP (the
only thing missing is the "new" before the class name, and the only new
thing is the word "attribute")

- This doesn't add significant complexity. It essentially makes
attributes autocalled class constructors. (As a side note, I don't think
any part of PHP is significantly complex, it just isn't
consistent--making it seem complex).

- It is quite clear that that line is an attribute. People will be able
to easily Google, find and read the PHP docs for an explanation.

I know we aren't supposed to go into syntax, but I am curious as to
people's reactions if things stay very "php-esque" instead of trying to
create a new syntax/imitate another language.

Also, don't get me wrong, I think parsable docblocks is a great idea and
I support it--just not for annotations.

On 11/16/2010 2:06 AM, Zeev Suraski wrote:
-----Original Message-----
From: Pierre Joye
Sent: Tuesday, November 16, 2010 1:45 AM
To: Zeev Suraski
Cc: guilhermeblanco@gmail.com; PHP internals
Subject: Re: [PHP-DEV] PHP 5.4 - Meta attribute (aka. Annotations) support

On Tue, Nov 16, 2010 at 12:39 AM, Zeev Suraskiwrote:
Suggesting phpdoc is used for the purposes mentioned does not mean we
don't understand what we're talking about.

I feel like you never used annotations in other languages, did you?
You got me... But as an intelligent human being I'd like to think I can evaluate the merits of a feature without having to actually use it.

I'm not saying that annotations don't give you any value. Sure they do. I'm saying that they come at a great price of adding an obscure branch of syntax into a language that's already grown significantly in complexity, and the bang for the buck isn't worth it. Those advanced developers needing that feature can make do with phpdoc.


Search Discussions

Discussion Posts


Follow ups

Related Discussions



site design / logo © 2022 Grokbase