Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64743 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20056 invoked from network); 9 Jan 2013 14:48:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Jan 2013 14:48:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=kontakt@beberlei.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=kontakt@beberlei.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain beberlei.de from 209.85.212.181 cause and error) X-PHP-List-Original-Sender: kontakt@beberlei.de X-Host-Fingerprint: 209.85.212.181 mail-wi0-f181.google.com Received: from [209.85.212.181] ([209.85.212.181:56668] helo=mail-wi0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 65/89-02684-7538DE05 for ; Wed, 09 Jan 2013 09:48:57 -0500 Received: by mail-wi0-f181.google.com with SMTP id hq4so566664wib.14 for ; Wed, 09 Jan 2013 06:48:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:x-originating-ip:in-reply-to:references :date:message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=5HpDHNlJdQO+i+C2z0LzI/POB4L2m0oYP7DG01Ja23o=; b=PNzS+g8HIzEy9oNngY004PLuUwff8Dsp66MLKnLFu55+ASKgKwQ102mRbhMphWAVKt vlHSiHZ9k+RkTx9/FGztdyyhMFXsh6shbFRzMbZJZzuCLlNs4kwpHZYTxFGEtlFq1Tw1 iMRURCUwfXfWUvgLWEte/mLjZSedNgbJo8Vakz6t3iUOHUrJRVHAEHTSm7aZbvIhsFHi vRGqOMWFBPSXAi98IAoq3e0XH54lpd+Lp8yOQ4uNCTJymdM0m0Wsf0Kh+qANJX/ovHIw 6uvMOVLjN47Ep2FAuZd5Jcv9Xpy6+ezTw5bSuBB2YA+zPeLANIcwZehRqPMYz0sDhVeb 4Xsg== MIME-Version: 1.0 X-Received: by 10.180.82.69 with SMTP id g5mr3770067wiy.21.1357742932971; Wed, 09 Jan 2013 06:48:52 -0800 (PST) Received: by 10.194.59.36 with HTTP; Wed, 9 Jan 2013 06:48:52 -0800 (PST) X-Originating-IP: [77.13.202.63] In-Reply-To: References: <50EBDEEE.8070605@sugarcrm.com> Date: Wed, 9 Jan 2013 15:48:52 +0100 Message-ID: To: Derick Rethans Cc: Vladislav Veselinov , Pierrick Charron , Stas Malyshev , Rasmus Schultz , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=f46d0442838a37508d04d2dc293e X-Gm-Message-State: ALoCoQkcq7erJ+P7zNEKpOt5dykMsTAxx69pxSaytlttCacnLsH5Nc5zDr8OsZFhC9QWqvXYOdkQ Subject: Re: [PHP-DEV] [RFC] Reflection annotations reader From: kontakt@beberlei.de (Benjamin Eberlei) --f46d0442838a37508d04d2dc293e Content-Type: text/plain; charset=ISO-8859-1 On Wed, Jan 9, 2013 at 1:42 PM, Derick Rethans wrote: > Please, no top posting!!! > > On Wed, 9 Jan 2013, Vladislav Veselinov wrote: > > > Taken from the Doctrine documentation: > > > > > class User > > { > > //... > > /** > > * @ManyToMany(targetEntity="Group") > > * @JoinTable(name="User_Group", > > * joinColumns={@JoinColumn(name="User_id", > referencedColumnName="id")}, > > * inverseJoinColumns={@JoinColumn(name="Group_id", > referencedColumnName="id")} > > * ) > > */ > > private $groups; > > //... > > } > > > > Not that I'm a fan of it, but it provides a valid usecase. I'm sure > > there are more. > > Maybe valid, but sticking this into core-syntax seems mental. > The Doctrine Syntax is verbose, because that is necessary to make up for the missing compile time support in the language. The core could easily offer a "simpler" language or one that looks more like PHP code (array syntax). If you take a look at annotations by starting with PHP code, instead of docblocks and the syntax optimized for that use-case you can end up with something much simpler, see: The most simple type of annotations is attaching metadata to a class, method, function, property. In Clojure this is actually done like this at runtime setting a hashmap to any structure. In PHP that would be something like: function foo() {} $refl = new ReflectionFunction('foo'); $refl->setMetadata(array('foo' => 'bar')); $refl->getMetadata(); Doctrine Annotations do allow "retrieving" metadata for any structure, sspecified in docblocks. For seperation we need something the Annotations RFC defined, a new type of docblock that is executable code wrapped in for example <> brackets, if this were just PHP code, then we'd have: 'bar'))> function foo() {} Now the difference between this syntax, and something resembling "Docblock Annotations" would mean that the last statement between <> is returned from the block. With short syntax for arrays we get: <['foo' => 'bar']> function foo() {} Now this is nothing new to learn for anybody, except that <> code for any structure can be "executed" using $reflection->getMetadata(); And the crazy people (like me) could do more structured things: use Doctrine\ORM\Mapping AS ORM; <[new ORM\Entity, new ORM\Table(name="user")]> class User {} --f46d0442838a37508d04d2dc293e--