Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89414 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31995 invoked from network); 25 Nov 2015 16:54:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Nov 2015 16:54:38 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.42 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.42 mail-wm0-f42.google.com Received: from [74.125.82.42] ([74.125.82.42:37667] helo=mail-wm0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 20/52-19088-CC7E5565 for ; Wed, 25 Nov 2015 11:54:37 -0500 Received: by wmww144 with SMTP id w144so77364142wmw.0 for ; Wed, 25 Nov 2015 08:54:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:from:to:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=InFIZjneE12M6l9bcnKvuk15nWCkVRMm6MG96kCOfh8=; b=PeualImFryoawceGVcIbryAe74z57uSbfANPcRXEUK3LeXp8oXIZ7GffGY7Y+YTK3F CsGbUQgBzeMsgSZFhtwHWgaR0Orl59NW9DohY/6HC+Mv9s2buGjH9cpK3PZoTUgyN4cc 6k16QWe2flTcNf3cioXpUl03ue5HSy9qA5fpzbqwfH5AGyiF5afp4vOK9C56FNezoXgF YvM7w/E2NblcNMmKeUbdH8CLFfQCVT6V88r/jalUra5gTBiHKuoIGSM3DpTe4/NvldY/ 9mKSSZC7sZTBnOGCozerLNeTHPQRNI14/15Ekooip9hx2IVQ7oCR4iXIYoG+aco7ujnS +InA== X-Received: by 10.194.243.227 with SMTP id xb3mr47749732wjc.96.1448470471238; Wed, 25 Nov 2015 08:54:31 -0800 (PST) Received: from [192.168.0.147] ([93.188.182.58]) by smtp.googlemail.com with ESMTPSA id 193sm4343186wmp.16.2015.11.25.08.54.30 for (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 Nov 2015 08:54:30 -0800 (PST) References: <5654B516.4020700@gmail.com> To: PHP internals Message-ID: <5655E790.9060408@gmail.com> Date: Wed, 25 Nov 2015 16:53:36 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 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: rowan.collins@gmail.com (Rowan Collins) Pedro Cordeiro wrote on 25/11/2015 11:04: > I'd really like to see something outside the docblock. Comment > annotations are a workaround for the lack of native annotations. This is true, but they are now a very widely used workaround, and any native support for them could be polyfilled using the kind of userland libraries that already exist. > It makes the environment hard to learn ("What does @param do? And what > does @ManyToMany do?") I'm not sure how this is made any easier by moving the annotations out of the docblock. I suppose it's a little confusing that, within the docblock, code annotations and documentation annotations share the same syntax; maybe we could use a different prefix, like "@@" instead of "@"? This would also give a chance for projects to transition to the new standard syntax, rather than having to break compatibility if their old implementation doesn't quite match. > it makes it impossible for IDEs to hint/autocomplete without > project-specific plugins That's a good argument for standardisation, but doesn't require moving out of the docblock; in fact, it doesn't even require any action from this list, as PHP-FIG could simply agree a PSR, and IDEs like PHPStorm would use that as an implementation guide. > and adds this odd notion that removing some comment blocks might break > an app (which is just awful). If it helps, just think of /** ... */ as not being a comment, but already a first-class piece of syntax. Note that the parser already thinks so - hence we can have functions like ReflectionMethod::getDocComment. IDEs also parse docblocks already, and most syntax highlighting editors can probably style them differently from comments so that you don't delete them by mistake. Now, if annotations were being implemented as something brand new to PHP, like say Traits were, I'd agree that we should look to languages like Java and C# for syntax ideas. But since a lot of people have already invented annotations using docblocks, and since docblocks are already supported by the reflection classes, I'm not convinced of why we shouldn't just carry on down that route. Regards, -- Rowan Collins [IMSoP]