Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83115 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35001 invoked from network); 18 Feb 2015 20:29:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2015 20:29:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=pajousek@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pajousek@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.45 as permitted sender) X-PHP-List-Original-Sender: pajousek@gmail.com X-Host-Fingerprint: 209.85.216.45 mail-qa0-f45.google.com Received: from [209.85.216.45] ([209.85.216.45:54005] helo=mail-qa0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3A/88-25021-836F4E45 for ; Wed, 18 Feb 2015 15:29:45 -0500 Received: by mail-qa0-f45.google.com with SMTP id j7so2623591qaq.4 for ; Wed, 18 Feb 2015 12:29:42 -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=mkYdBpoXIJdhRx1vRTq1ecmvJTjCtN8IlQJKmaFxIEg=; b=Y6YXxmKj4T7sx2iLKOqWRR3y1xQQeLOKJrKbwwMXY7VoNa2wIKZOPSpV+2yIZUux+c RwPnEqKfjuLEl63ssS1P2udwt/Xl+aUXPpj7KrvrdjkE0WEnbE1k8gEoIc1UmOWnlsxD pGTFfkMcq1uMD0BfBZ+QMwYD31veheCw49xUE1BUwWpIuCgEoSKzIoZSkb82poP6h5eT Xz29PPiUP4KZA3oeKNbOhSIfCw1VAbkpu+NsDzM/gL4x8605tScjHNslvgLzHgr5veGs M6bkpH6JGDJBhupsOFYWls6j6uyKnAmh8BTnLb6Hy51W8uuFj31JrPv8dnRk55q2VZKj Vmvg== MIME-Version: 1.0 X-Received: by 10.140.231.151 with SMTP id b145mr4084866qhc.22.1424291382179; Wed, 18 Feb 2015 12:29:42 -0800 (PST) Received: by 10.96.63.169 with HTTP; Wed, 18 Feb 2015 12:29:41 -0800 (PST) In-Reply-To: References: <02a101d04af9$507484f0$f15d8ed0$@php.net> <02ff01d04b72$abae34a0$030a9de0$@php.net> <032801d04b8d$8ff3dce0$afdb96a0$@php.net> Date: Wed, 18 Feb 2015 21:29:41 +0100 Message-ID: To: "guilhermeblanco@gmail.com" Cc: Dmitry Stogov , francois , Benjamin Eberlei , Alexander Lisachenko , Nikita Popov , PHP Internals , Pierrick CHARRON , Pierre Joye , Zeev Suraski , Andi Gutmans , Joe Watkins , Yasuo Ohgaki , Sebastian Bergmann , Stanislav Malyshev , Rasmus Lerdorf Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Annotations in PHP7 From: pajousek@gmail.com (=?UTF-8?Q?Pavel_Kou=C5=99il?=) On Wed, Feb 18, 2015 at 7:28 PM, guilhermeblanco@gmail.com wrote: > Hi Dmitry, > >> Are you (and Doctrine team) interested in this annotation idea? > > I'd say that Benjamin nailed in our possible usage: > > > class Foo { > } > > Now I do feel we need to elaborate some sort of named parameters. Doctrine > tries to simplify a lot developer's life by using consistency in default > mapping and only if the user wants to override default behavior he needs to > override a given parameter. This means in a case where you're mapping a > JoinColumn ( > https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/JoinColumn.php > ), > you may only want to specify the onDelete="CASCADE" operation instead of > name, referencedColumnName and many other parameters. > Trying to map this in your default parameter passing, we'd have something > like: > > [ > new OneToOne("Address"), > new JoinColumn(default, default, default, default, "CASCADE") > ] > )> > public $address; > > As I said, named parameters make a lot of sense when mapping defaults. > Now by looking at this syntax, I still think we're closer to a simple array > implementation (ReflectionClass::getMetadata(string $name)) and having > something like: > > <[ > "orm" => [ > new OneToOne("Address"), > new JoinColumn(default, default, default, default, "CASCADE") > ] > ]> > public $address; > > > PS: We haven't even started on talking about overrides yet... =\ > As a Doctrine user, I find this way worse than current state. This syntax looks UGLY and contains a lot of useless clutter. And yeah, adding named parameters to PHP be pretty helpful to make annotations more readable. :( And to what Francois said ("Anyway, I don't like the OO features people want to add everywhere. They can get strings and inject them to OO, but that's not the role of the annotation layer, IMHO. I definitely prefer the KISS approach."). What's exactly wrong with doing annotations in an object oriented manner? Both Doctrine Annotations and C# have them as objects, and it works well. Having annotations as just array of expressions/strings/whatever and needing another library to parse them is not really that great "upgrade" from current state. :( Regards Pavel Kouril