Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89403 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96897 invoked from network); 25 Nov 2015 11:04:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Nov 2015 11:04:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=pedronaroga@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pedronaroga@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.182 as permitted sender) X-PHP-List-Original-Sender: pedronaroga@gmail.com X-Host-Fingerprint: 209.85.160.182 mail-yk0-f182.google.com Received: from [209.85.160.182] ([209.85.160.182:33503] helo=mail-yk0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A7/92-14932-2C595565 for ; Wed, 25 Nov 2015 06:04:35 -0500 Received: by ykdv3 with SMTP id v3so51764505ykd.0 for ; Wed, 25 Nov 2015 03:04:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=WmdWE+SShqxbVYDOxGsPQSWyGiq9+0OmuwHT+ixNia8=; b=TIeLKaZmQe0kOTULwMwO5KI//MQ3IVP2LzRq41KknBMiTchQv8K5BDsb6hfLxxEjVC oMpPQSJ3d3sLzYMGYXMfkkzChCAte7sm1GpkhgqPD5M8R6nDBi/jZMN9lgL17D+x2vc2 nhaWSeWf07D/WYS71WR690Hd9oZc7j8hmJJ6TPkxPxERMhmYeSo4wO1DpAtGEeT1s2qO UHKN8ln8DvDB7dK/kRREjPoR8++PiLAV9bI447/H6ckWXN58THtgyxwiXxdXMAz7EBny i4d4ddsNYKrUKlkr9ljUQyeXZwQ6Hg2NtIfC3YHzHHx7f46xDacES3tLnQSy8i/75Imv rWpA== MIME-Version: 1.0 X-Received: by 10.13.225.132 with SMTP id k126mr27808131ywe.237.1448449472075; Wed, 25 Nov 2015 03:04:32 -0800 (PST) Received: by 10.37.202.9 with HTTP; Wed, 25 Nov 2015 03:04:32 -0800 (PST) In-Reply-To: References: <5654B516.4020700@gmail.com> Date: Wed, 25 Nov 2015 09:04:32 -0200 Message-ID: To: Sara Golemon Cc: Rowan Collins , PHP internals Content-Type: multipart/alternative; boundary=94eb2c07709a421e9405255b6c95 Subject: Re: [PHP-DEV] Native Annotation Syntax From: pedronaroga@gmail.com (Pedro Cordeiro) --94eb2c07709a421e9405255b6c95 Content-Type: text/plain; charset=UTF-8 I'd really like to see something outside the docblock. Comment annotations are a workaround for the lack of native annotations. It makes the environment hard to learn ("What does @param do? And what does @ManyToMany do?"), it makes it impossible for IDEs to hint/autocomplete without project-specific plugins, and adds this odd notion that removing some comment blocks might break an app (which is just awful). @beberlei, I had searched through the archives already and couldn't find the vote. I found the discussion (in which many people advocated for docblock annotations), but didn't find the vote. I feel like this is a major feature that's missing, and people are using it in a suboptimal way (docblocks), so I thought I'd reopen the discussion and see if someone more familiar with the internals feels like implementing it (I don't feel confident enough since I've never tried messing with into the internals). 2015-11-24 22:31 GMT-02:00 Sara Golemon : > On Tue, Nov 24, 2015 at 11:05 AM, Rowan Collins > wrote: > > At first sight, these seem like details which could be tweaked later, but > > they make a difference to what syntax to standardise: is the annotation > name > > just a string, or a valid class name? is the value of the annotation > just a > > string, or a parseable PHP expression? is it more useful to use the de > facto > > existing syntax in DocBlocks, or to add a new keyword or operator? etc > > > If we're going to use something in the docblock, then I wouldn't want > it parsed on compilation, but rather have it be an on-demand parse > while reflecting. The reason being that there are plenty of > docblock'd PHP libraries out there using invalid annotations because > they're not running it through tools to tell them what they got wrong. > Waiting till they've actually tried to examine it through reflection > lets us throw an exception on code that cares about it rather than > preventing code which ignores reflection from running. > > I, for one, am a fan of Java style annotations which allow a string > name plus optional metadata. > > @@foo > class Bar { > @@Baz("something", 123, [ 'a', 'b', ''c']) > public function qux() { ... } > } > > Though the formality of having to define the annotation as an > interface is a bit overkill for PHP, the same rules Hack uses would be > clear and simple enough: > > <> > class Bar { > <> > public function qux() { ... } > } > > And no, I'm not picky about the parser symbol used... In fact, > allowing an optional '//' prefix to annotations might be nice for > compatibility. > > -Sara > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --94eb2c07709a421e9405255b6c95--