Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93022 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58618 invoked from network); 1 May 2016 19:47:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 May 2016 19:47:40 -0000 Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; 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:49529] helo=out5-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 38/D4-03860-B5D56275 for ; Sun, 01 May 2016 15:47:39 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 831442043B for ; Sun, 1 May 2016 15:47:36 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Sun, 01 May 2016 15:47:36 -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=DnFMX6S4mmBGZE0 UWQnQ4OUv2Ak=; b=SeWEOs3eWH2OdPI1k7SWObtWi3S9DSY87hOX7RyvJ4Rqk+d qd/kGpILWLGQMSZdIiMbgjdH4f8hyTsZhVdLhwmDR/uAcWcIoAi3K/BYF1HjUbiV sqLmEUD4BYl4viNrP2o8WeJRhf97lZR/FsckFzjgd6Wz4Gm3hDDQXT/kI0I4= X-Sasl-enc: LHHLTFmJe3Tgoa7LsuR9ntgLCRDM67dAKi4sZ9mABhdv 1462132056 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 3616C680120 for ; Sun, 1 May 2016 15:47:36 -0400 (EDT) To: internals@lists.php.net References: <5723F2AE.2020806@garfieldtech.com> <572529F2.9070606@garfieldtech.com> <8e4ed849-f504-fe80-3c5f-e4ea114e99fa@gmail.com> <6e3f41ce-4dd5-cd29-a063-fdc9c9c920b8@gmail.com> <830b1059-9a9e-b7e1-e338-29d562588e2f@gmail.com> Message-ID: <57265D57.1040301@garfieldtech.com> Date: Sun, 1 May 2016 14:47:35 -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/30/2016 06:21 PM, Rowan Collins wrote: > On 30/04/2016 23:45, Stanislav Malyshev wrote: >> Oh, of course you can have methods, but then it is strange conceptually >> - you have a normal class, which some other part of the language just >> uses for something else that classes are not routinely used for. I.e., >> does it call a constructor? When? With which arguments? What if it >> fails? What if I just create an object of this class - would it be the >> same as annotation object? > > Hm... I was going to say "well, PDO does this if you use > PDOStatement::fetchObject"; but then I remembered that the integration > with the object there IS a bit weird - it injects raw properties, and > *then* calls the constructor. > > So, I'm not sure there's a limitation in terms of the object being > data-only per se, but there are certainly oddities to be dealt with in > terms of construction. And as you mentioned, mutability leads to > another set of oddities - are the mutations stored for next time you > request that annotation, or is the object recreated on each access? > > Regards, It would never occur to me to not have it regenerated on each access. If I want to cache it I will do so myself, thanks. :-) However, that is not an issue created by using a defined structure for the annotation result. The RFC currently says it returns an associative array, aka anonymous struct. Those are always highly mutable. A classed object is as mutable as its design allows it to be. To wit: <<__Annotation>> class Definition { protected $foo; protected $bar; public function getFoo() {} public function getBar() {} } < 1, bar => 2)>> class Meep {} The resulting annotation object would be an instance of Definition, which is for practical purposes immutable. If it were returned as an array ['foo' => 1, 'bar' => 2], that would obviously be mutable. Whether Definition should have mutator methods on it then becomes the implementer's decision, which is probably for the best. --Larry Garfield