Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92995 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45969 invoked from network); 30 Apr 2016 17:54:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2016 17:54:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 66.111.4.29 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.29 out5-smtp.messagingengine.com Received: from [66.111.4.29] ([66.111.4.29:38802] helo=out5-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6F/FC-58459-941F4275 for ; Sat, 30 Apr 2016 13:54:17 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 58BD62075C for ; Sat, 30 Apr 2016 13:54:15 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Sat, 30 Apr 2016 13:54:15 -0400 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=BeNcE539xxDLkA1 Rxt+rQC5eTcU=; b=CKMMmjeYckRfpTpRW6Awg6JYxpmP0GW5qV041DuuN79/iJv mdjoicNr+062VApOirqz12eqSkf9RG0y10nUcu7ZyC1l89Lppkskkt1V8KC59cvz hcTrJjjfYHOjV/glO78DQ+LHfEb+uTvLNP/WxetPrOZyZUTod+Hv4KoQ8nN0= X-Sasl-enc: +K9gqxwya3tQsRQFql5OawVYqsmDeUXyCzNpDw3ygPYh 1462038855 Received: from [192.168.42.5] (c-50-178-40-84.hsd1.il.comcast.net [50.178.40.84]) by mail.messagingengine.com (Postfix) with ESMTPA id 14675C00012 for ; Sat, 30 Apr 2016 13:54:15 -0400 (EDT) To: internals@lists.php.net References: <5723F2AE.2020806@garfieldtech.com> Message-ID: <5724F146.5010206@garfieldtech.com> Date: Sat, 30 Apr 2016 12:54:14 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.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] Attributes/Annotations Case Study: Drupal From: larry@garfieldtech.com (Larry Garfield) On 04/29/2016 11:54 PM, Pierre Joye wrote: > Hi Larry, > > On Apr 30, 2016 6:48 AM, "Larry Garfield" wrote: >> Most of the examples that have been given so far are either trivial > boolean flags or data validation rules to be evaled. In practice, very > little of Drupal's use of annotations in Drupal 8 fit either category. > Rather, they're used primarily as, in essence, a serialized metadata object > describing a class, which is used for registering that class and > potentially others. I figured I'd give the proposed syntax a try with some > Drupal examples and see how well it fit. > >> Disclaimer: I'm sure someone will pipe up with "your use case is invalid > because you shouldn't be using annotations that way." > > What I would like to say yes. Very very loudly. But I am not sure about > what is what or what defined what in your complex example > > Do you have a link to the source file so I can make an informed reply > please? Sure. The block annotation is defined here: http://cgit.drupalcode.org/drupal/tree/core/lib/Drupal/Core/Block/Annotation/Block.php And the particular block plugin that I showed is here: http://cgit.drupalcode.org/drupal/tree/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php The annotation for a content entity is here: http://cgit.drupalcode.org/drupal/tree/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php And the Node class is here: http://cgit.drupalcode.org/drupal/tree/core/modules/node/src/Entity/Node.php Note that in both cases I omitted the base class definition and such to focus on the annotation. Drupal does make excessive use of inheritance. I have been vocal about this problem for some time, but it will take a little while for enough people to experience the pain of poor design choices for them to get on board with better ones. Nonetheless, an annotation system in core should be informed by real-world usage, and Drupal is now a very significant real-world usage. Also note that because Drupal is so heavily configuration driven, many many things must be more dynamic and abstracted than they would in any bespoke system. That's why Drupal tends to over-do so many things; it's necessary to achieve runtime-configuration-driven data modeling and display business logic. --Larry Garfield