Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89411 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26712 invoked from network); 25 Nov 2015 16:42:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Nov 2015 16:42:19 -0000 Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 66.111.4.26 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.26 out2-smtp.messagingengine.com Received: from [66.111.4.26] ([66.111.4.26:51659] helo=out2-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 28/21-19088-7E4E5565 for ; Wed, 25 Nov 2015 11:42:16 -0500 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id EB1F2208DF for ; Wed, 25 Nov 2015 11:42:12 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Wed, 25 Nov 2015 11:42:12 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=5Kowf9X+OXczqah hmYZQBKIhdCE=; b=qhTUPxagUBb0ryDUgQSfEoB5i/BOMuCdikdNrxdmncRJGB5 jSi6qXj8g+AQhCpFc7WWZD6F4ZwHWsYWQ+YGnlvR+xUi605U7CKpMN4n82l8rpqv kIwCQ7oKxwBM++qN/MHQU7KUORbsd0GNZfKFme/2q9sdSGGbdUyWIU+4fIBk= X-Sasl-enc: dKFdbNR6s0E4YgCaPXJw3f4RjuS/KRaXeCoEtH0XEhwu 1448469732 Received: from Crells-MacBook-Pro.local (unknown [63.250.249.138]) by mail.messagingengine.com (Postfix) with ESMTPA id A99526800CC for ; Wed, 25 Nov 2015 11:42:12 -0500 (EST) To: internals@lists.php.net References: <5654B516.4020700@gmail.com> <5655D82A.8020304@lsces.co.uk> Message-ID: <5655E4E4.8070200@garfieldtech.com> Date: Wed, 25 Nov 2015 10:42:12 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Native Annotation Syntax From: larry@garfieldtech.com (Larry Garfield) On 11/25/15 10:31 AM, Pedro Cordeiro wrote: > 2015-11-25 13:47 GMT-02:00 Lester Caine : > >> Any new system would require >> every third party tool to be adapted to use it >> > That's not true at all. A new syntax would in no way invalidate parsing > annotations from docblocks. > > The only legacy code that is supported by IDEs (if they are, PHPStorm will > not hint/autocomplete, nor will eclipse/netbeans) would be > Symfony2/Doctrine2. There are tons of other tools that with custom > annotations (JMSSerializer as an example) that do not have any support at > all. > > This argument is so flawed that you didn't consider that there are many > parsers with many different syntaxes ( > https://github.com/jan-swiecki/php-simple-annotations, > https://github.com/nette/neon) and that ANY implementation, be it through > docblocks or with a native syntax would require a rewrite anyway for many > projects if those tools want to support the new native feature. > > Also, doing it through an extension is a nice way to delay adoption, > because shared hosts rarely give the option to install new extensions. > > I don't have a vote here, but if I had, I'd strongly oppose any > docblock-based implementation. When Drupal adopted annotations, the absolute #1 objection people had was "but docblocks aren't code, you moron!" There's no value in language-native annotations being in the docblock, other than BC with *some* existing implementations. However, doing so would make static checking more difficult; If annotations become a language-native feature, they should be a first-class citizen to make it easier for IDEs to handle. I'm also not super picky on what the tokens are, however I do think mapping them to actual classes, like Doctrine does, would be the most flexible. Structured data all the things. That also means annotations can be namespaced, be affected by use statements, and so forth. In a sense, they become isomorphic to: class Foo { public static function getAnnotations() { return [ new OneToMany('a', 'b', 'c'), new Stuff('d', 4); ]; } } Except they can be applied to anything reflectable rather than just classes. (Functions, methods, classes, object properties.) Sara's suggestion of making them legal within a // comment line for BC reasons is interesting, but we don't do that for any other new syntax AFAIK. Plus, it means it's harder to comment out an annotation temporarily for debugging. There's still /* */, but it's one more quirk to have to think about. -- --Larry Garfield