Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92737 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57732 invoked from network); 25 Apr 2016 16:49:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Apr 2016 16:49:13 -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.26 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.26 out2-smtp.messagingengine.com Received: from [66.111.4.26] ([66.111.4.26:49713] helo=out2-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 92/4A-00233-68A4E175 for ; Mon, 25 Apr 2016 12:49:10 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id BA3EC29E1A for ; Mon, 25 Apr 2016 12:49:07 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Mon, 25 Apr 2016 12:49:07 -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=ESo9uoDgVJNIcGh +rioGHDZILvA=; b=kPm+VYxHff3od+m8RVXm6XZHvtuEUPgB/v/Wsr7cDVXW2cv 5okOvN2jnALftYbX4qwiX6YhQJnlaWsCmAPSvrwDUMGeBZYQRlc/Gu/8eUaDIZTc UqjFgWv3Di1+0E/CD6tlTGH7+3E65y2GcyX7aqgZVQvgaNEuYbr/38qQGUS8= X-Sasl-enc: 8Y9dIN286Y1yajc1Se4qsT4DGd7lpNEOd5WaCJrzGVq1 1461602947 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 7BC5CC0001E for ; Mon, 25 Apr 2016 12:49:07 -0400 (EDT) To: internals@lists.php.net References: <571965D1.9020102@zend.com> <5719CDB2.90103@zend.com> <571DCA6A.2070803@zend.com> <571E35D8.8080504@zend.com> Message-ID: <571E4A83.3080304@garfieldtech.com> Date: Mon, 25 Apr 2016 11:49:07 -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: <571E35D8.8080504@zend.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] PHP Attributes From: larry@garfieldtech.com (Larry Garfield) On 04/25/2016 10:20 AM, Dmitry Stogov wrote: > >> This leads to some serious copy/paste, highly error prone... =( > > If we had a theoretical approach for attribute inheritance, I would > implement it. > But I wouldn't invite any theory, because anyone is going to depend on > use-case. Realistically, I see only 3 possible approaches to consider: 1) An overridden class/property/method always inherits its parent's annotations/attributes, and you can add to them. 2) An overridden class/property/method never inherits its parent's annotations/attributes, but you can repeat them. 3) Give users a syntactic toggle. >> As I said earlier, if you do a call based approach, we could create >> @Inherit or @Override, which would not only make us safe from >> support, but also gives more power to developers. > > If we implement built-in @Inherit and/or @Override, it's not a big > problem to copy attributes from parent. If I understand you correctly, that would be option 3. I would support that as well, as it's consistent with how methods work: By default, they override the parent method but you can call parent::whatever() to toggle the parent behavior back on. Thus, I would suggest that when overriding a class/property/method that has annotations, it NOT inherit annotations/attributes by default. However, by adding an annotation of <<__inherit>> (Or some other internal-reserved keyword, I don't have strong feelings on what it is) then the engine will automatically give you all the annotations off of the parent, and union them with whatever additional ones you add. That of course raises interesting questions around interfaces and traits, and how annotations on those comingle. Should annotations on interfaces auto-apply to their implementations or should they require an explicit <<__inherit>>? I'm undecided. --Larry Garfield