Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92739 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61024 invoked from network); 25 Apr 2016 17:04:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Apr 2016 17:04:31 -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 74.125.82.51 cause and error) X-PHP-List-Original-Sender: kontakt@beberlei.de X-Host-Fingerprint: 74.125.82.51 mail-wm0-f51.google.com Received: from [74.125.82.51] ([74.125.82.51:35929] helo=mail-wm0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 72/FA-00233-D1E4E175 for ; Mon, 25 Apr 2016 13:04:30 -0400 Received: by mail-wm0-f51.google.com with SMTP id v188so106199192wme.1 for ; Mon, 25 Apr 2016 10:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beberlei-de.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=tKr/JB/jZFj+6khiBOSfytaBAObhpQ+6aTOoGeG2Lng=; b=r3aImkc0KwAJclsYqpboS7Pz2fglPd58Vn0Ix3c9RB/D3jOow9iIZd8fKVLcmxbNZy zyauLS2ETHEiBjnhskmHO7gA19QVDaTq1cBqTWB3M9oOT/Oj29ZQZviMab11ouR7PNHu 1IGeZwFRB+ePEbCH6u+XaelodTxGwI2gQoP8QmCRy6oMOw7tYRJZD0+xNHV7fUz3USIN dgREPjf1WprJ782C7tTwlEc6fD2xWKtuEJuwn7kgTz6NKx8/nGCUfDigds7/CfXgxZQo mdCwmmHGfGk/yigEk5WdMGxJajgt+/dmMf/+LfFF8TauCzovUhskCEg4V3h+WchJ3yGM iNOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=tKr/JB/jZFj+6khiBOSfytaBAObhpQ+6aTOoGeG2Lng=; b=ULrs0/pYxK+QRtwZH2CrTosODdEsNQIlzJlYSYRSlqe92YS+DU8gyKFNdswqBkcJaf cdZLOzMnbJTjvfp+bhJCVEqO7l520RCDDY/0fILvKoS9NpGmpASjXHcR8yv964d+KZXf DWxivjc5zG+x2t26VTTPO9o85uwyLjbWu9u4tUSN52gd4AOkGvSKvLVM+RfkZ7JQkUcl Y3cfPR87jM3gSoq/sgkNgacITV9lzRjQ2qsBp5zqMuI9vA9r5ypqQ8KF4b5gls5EjWEb /3ss+J4TmQjdLT8DSEs2Ipo7PKJsxEx+uYr1pHBeGCLETvGzGkjjLdR4aUJz84lFcazG h0nA== X-Gm-Message-State: AOPr4FU96RapdZfyURXpdvuhO2vT8VwUl/EAzPo/ZENNnZlEOxqVyEaQQZLEhyhh9x35oI3vVVvNw6FHTFlpuw== MIME-Version: 1.0 X-Received: by 10.28.4.149 with SMTP id 143mr12941745wme.44.1461603866487; Mon, 25 Apr 2016 10:04:26 -0700 (PDT) Received: by 10.194.94.163 with HTTP; Mon, 25 Apr 2016 10:04:26 -0700 (PDT) X-Originating-IP: [93.129.168.204] In-Reply-To: <571E4A83.3080304@garfieldtech.com> References: <571965D1.9020102@zend.com> <5719CDB2.90103@zend.com> <571DCA6A.2070803@zend.com> <571E35D8.8080504@zend.com> <571E4A83.3080304@garfieldtech.com> Date: Mon, 25 Apr 2016 19:04:26 +0200 Message-ID: To: Larry Garfield Cc: PHP Internals Content-Type: multipart/alternative; boundary=001a1141d29443d02a0531522b40 Subject: Re: [PHP-DEV] [RFC] PHP Attributes From: kontakt@beberlei.de (Benjamin Eberlei) --001a1141d29443d02a0531522b40 Content-Type: text/plain; charset=UTF-8 On Mon, Apr 25, 2016 at 6:49 PM, Larry Garfield wrote: > 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. Why do we talk about inheritance at all? ReflectionClass/Method/Property already have a well defined way of accessing the inherited data. Why should it work differently for ReflectionAttribute: Demonstration of how to get access to overwritten doc comments in case of overwritting a base class: https://3v4l.org/6fRdn Attributes should just work exactly the same and we are done. > > > 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 > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a1141d29443d02a0531522b40--