Re: PHP 5.4 - Meta attribute (aka. Annotations) supportdiscussion
| From: | Dave Ingram | Date: | Wed, 17 Nov 2010 07:44:31 +0000 |
| Subject: | Re: PHP 5.4 - Meta attribute (aka. Annotations) supportdiscussion | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-50288@lists.php.net to get a copy of this message | ||
On 16/11/10 21:56, Alec wrote:
> [snip]
>
> attribute RestMethod('/do/something', 'Do Stuff', 'Does
> something.',
> array(
> 'arg1' => 'A cool argument!'
> ));
> public static DoSomething($arg1) {
> ...
>
> or
>
> 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.
As a karma-less user, I actually quite like this syntax and it feels
very PHP-like to me. Making it trivially easy for people to search for
the explanation of a feature is an excellent idea.
Dave