Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92709 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94264 invoked from network); 25 Apr 2016 07:51:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Apr 2016 07:51:41 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 207.46.100.143 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 207.46.100.143 mail-by2on0143.outbound.protection.outlook.com Received: from [207.46.100.143] ([207.46.100.143:3904] helo=na01-by2-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7B/21-17738-B8CCD175 for ; Mon, 25 Apr 2016 03:51:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=RWSoftware.onmicrosoft.com; s=selector1-zend-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=7YtHFdh8oVkJIbLvqYat+hSUx92czhNu2uCfESNanCY=; b=TA2jzctYMP8T/ltqRinwZeg08nAOBJYaO8OwknBbiKArkWUiaaNDV55FUHqZaN0FsPOqeYa1GE0Fz76xJ0kI5araOki4R5QLBgbi0Hztf7fUx876i/OjwQkIQODZ40NOspJTVbWpIS6JRwAA8/QPM6+lgUNyXnrl2D5K0y2/8UM= Authentication-Results: lists.php.net; dkim=none (message not signed) header.d=none;lists.php.net; dmarc=none action=none header.from=zend.com; Received: from tpl2.home (92.62.57.172) by CY1PR0201MB1785.namprd02.prod.outlook.com (10.163.55.18) with Microsoft SMTP Server (TLS) id 15.1.477.8; Mon, 25 Apr 2016 07:51:34 +0000 To: Larry Garfield , References: <571965D1.9020102@zend.com> <5719CDB2.90103@zend.com> <571A499D.4090200@garfieldtech.com> Message-ID: <571DCC78.7070209@zend.com> Date: Mon, 25 Apr 2016 10:51:20 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <571A499D.4090200@garfieldtech.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [92.62.57.172] X-ClientProxiedBy: VI1PR02CA0010.eurprd02.prod.outlook.com (10.162.7.148) To CY1PR0201MB1785.namprd02.prod.outlook.com (10.163.55.18) X-MS-Office365-Filtering-Correlation-Id: 7c402101-47eb-487e-2f33-08d36cde6cea X-Microsoft-Exchange-Diagnostics: 1;CY1PR0201MB1785;2:aj7PkKSj7fvfODxw2QWAAvlnVBfkob5+bikFLBrhiVImU+zEitp9UfhDKfR1Z/hmsHKtIBBJ8hlhf17dLPX4p5dcGgBxxDYLEyaOCXnnvVUPSaqrh/dRcT4qBw6w5lXU2SnUp5YLOHX32Zmseo2+cxCbudNrXhaBk59h3SVWTijiijNTUyNAS8XqwSQEQ4o4;3:U3kH232uHw6AWsUOXAsPprbBmw2j/cROKGND6SHl5R9WH7Y/edOAKu3EzKlVgg6oIjaSgEEmRi2btPbLYp7WqOipEuLctBtlSZ7BSorbNiNL2Av2R783YJSO+XZRnTE1;25:n5RKIJii706Hb3Ivv3O1/KMa1THW63INeYGIK7CR1pu+m0nswd7RkSt/PLAog5nMVsRqCMiBvgukxJVHN1Y1aof5WhO/3aRZt23cnTVarqzXVJ8s6SepoVnSS+vbQ/aedm/vk5AoYHeA5SeWWLxrz+B/WniaOxGlTsA/5v3NFA4xkTHxB6xVBXWW/545OnMoDYilxX6SGT9adQlrbfRaau2BbP1rpSRcEHjn47GoTwq/vG0Q7a6MwnvOCRa8haCq6ZOLakex5sONFFfJmPytQ2Ae2Ea/8MfFyqS/1LefKWtkRyJO/Wsab3+4AvkRmMuZEO+Q+mH921ep1WjXbbSCBQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0201MB1785; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0201MB1785;20:Te73wuqa5gNQ/Iz/b67fLfTr9FllUYIa84sX/jm2Yack7n/ws695XGOlbEliqhvwl8kdON9EDSN6Pf5JxDDTW6KFQDgji+la+l3j57IndUq7XWzrppEXpoqA0CSIvy+YWc7HTmFcRDlWKsa3LxluIxmiP99vRPpBgcuds5zfxVjfQx8ilnrAePp5jwhtd0Xn2fPmsRun5StDH82x+r/xsXQDNbmXeE+5N5WhlKDON7ynTorCMXpDZzMCNvjq5P8TrAWZIppYY046yVqF4WVQejTyUF0ol4e7doIVqDuZjz/giymRI22VLo+26eoSNT3yZ7fsSJrqJzeSz3o3suWSmpXlXBoSuEj6W6M+e8a3P6XIxd5Zl1EgJh2s2Len4LisZ9Zl9VUZRyGKRA8pc8SPb/82lgd8ccbAuVEhIz7ZxI4WyUb5Q4SHKzMrSGe/OZAqag25l8MOl3QxViLdAsxXs8bIpNiJ0oKdMJ95Z/k5Mlf/9wPDCg70L+H3avpzQjmA;4:G0SKUnS8yvmftu8MQwUnoZ3EpwcH1F72mkAqyjUzH5UYdAX7HcYnftK7Yuv9+Fh+dFF+OAtstu3lvpSJc7UkTZ79Z/pwTtLu5ZT7hRzepbEnDZS07kucPO9u2xUMEJgGdExcnH7M+mEen+r2cQp+IBKYnGoywiWp38JsKmdCbxB7HwgZmM1xHwfdcumb5JdHPkcLNzg9q51LrrQYUtV6bUJdGaR9pu8c1mWHV9ofa5XCEaf9cDvW/i9uXcfW0ZVIl+yQ1/VvCkXuN6ZpSjLbzA0Tk2h0fQGboJouS4lTScPHGU/o+0XpKJdUMLBrzzevOrHMBUi87sI+qFcOHUjp4rm+qsciKN5Hg7NCW6BgbcGAHIXYmqSFOXjNsLfvKhlhNqCMXTrXyXuot4QuueZDnw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(9101521062)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046);SRVR:CY1PR0201MB1785;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0201MB1785; X-Forefront-PRVS: 0923977CCA X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(377454003)(24454002)(36756003)(19580405001)(189998001)(19580395003)(2950100001)(77096005)(230700001)(81166005)(87266999)(16799955002)(83506001)(2906002)(59896002)(50466002)(92566002)(76176999)(54356999)(5008740100001)(64126003)(6116002)(3846002)(50986999)(5001770100001)(93886004)(107886002)(33656002)(1096002)(65956001)(66066001)(65816999)(42186005)(586003)(86362001)(23676002)(47776003)(5004730100002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0201MB1785;H:tpl2.home;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTFQUjAyMDFNQjE3ODU7MjM6SUROYVRMT1hOYXIydzIwRmNBajlsK0Yv?= =?utf-8?B?YVByeVRKcU5DREZRa1FTVldsL0RoNDlsdk04ZmZnMjlpSUhrV2RXaGtMU0Js?= =?utf-8?B?K1F4a0hheGpXNWtUUWFRdy9zWXR1dmxkM29XSUxId01leGdlTkJGdVcrRlhS?= =?utf-8?B?SXFSb0h2TkMyam4rUjNQVHE2akFMOCtOcm9jeWRBc0lxN1FtUm92MDNPbWQ4?= =?utf-8?B?Nm9nNmNNa3p2TXlCSjJSek9YckkrWjJTbGRRY1pnMUw0aE4xZDdtakRHR0Vt?= =?utf-8?B?am9PbVNQbnMvWnFmbE5JazNxOVdkdjZpWDJpakxlOXNmdVlUL3lOaStsU3kz?= =?utf-8?B?MnN1dW1yNVZZWHZ2RHlybVZ5RGJGN0tOdzk2Z25qOUxNVVJ6N2VNUERJaG40?= =?utf-8?B?MWc0SVE1MkFRU2dDQy85a3RBblFLM0p0Mll0Z05WSDNmR0x6YmZqK2JreGdT?= =?utf-8?B?e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JROEN6QVNPYVJC?= =?utf-8?B?QmhwakI1dzFQdHgzK1dTdEVkaGNpTkpKVFZNakxDbW11dlJ1RzBsaWtUYUZr?= =?utf-8?Q?HjIo/RgYzjU3viss11nSS2+lArpzy?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR0201MB1785;5:mKcXqGqKY1MqSMoz5NpNeG1TQ4wfM5D+16BAtGCOmN5g2PG/MDfpoQ1dlJ5/pkGMZFYVSl8I7M66KqScac0bqwNQok5rRwiV3ANQGGc5GIritemwJlSxqaYMrqxw0h27PWZdiht+yHMEMBh02kk6Xg==;24:9TXM6P8EZlQKZcIDF0Hf+Ah84iYA/U6qzHwtZuga+YS0hX5W98N0UdtpBr37Hdp6DSCNPFZ9OclS8w5MCij67F2NFqsgj5Y5Y1yME4n4d3E=;7:h5UO8oybg1v2CwdRy/fGse9ZohZPYJfpDe2eSVO8tEU6I2lG+SBqSjA12wWF4YfmFt95K+aicbs2EgBDnBs84A4mmciQn2Iwmf6WCCKFd58hNTx3u2OriaLF7Rjr6SdItmGuQr+Exd+PyMqtMljphPWD2AXGB4xyq7D2h+uVmoK1ivjbyCJ1nlTymKZQrlnR SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2016 07:51:34.6447 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0201MB1785 Subject: Re: [PHP-DEV] [RFC] PHP Attributes From: dmitry@zend.com (Dmitry Stogov) On 04/22/2016 06:56 PM, Larry Garfield wrote: > On 4/22/16 10:39 AM, guilhermeblanco@gmail.com wrote: >> On Fri, Apr 22, 2016 at 3:07 AM, Dmitry Stogov wrote: >> >> >>> >>> 3- Did you put any thought on inheritance? What I mentioned in >>> comment #1 >>> is even smaller than what you implemented in RFC. >>> Assuming you keep the RFC approach, did you consider support overrides, >>> inherit, etc? >>> >>> >>> In my opinion, attributes don't have to be inherited. >>> If you think differently - please explain your point. >>> >> Of source I can. >> A simple case would be to increate visibility of the inherited >> property. It >> was declared in a parent class as protected, but now you want public, >> and >> you still want to keep all parent defined Attributes. >> Another example is like we do in Doctrine. We support a callback system >> which we named as lifetime callbacks. Pre-persist is one of them, >> which is >> called every time a given Entity is about to be persisted into DB. When >> you're dealing with inheritance, you can potentially override the method >> content and you still want to trigger the same operation as if it was >> untouched. Example: >> >> use Doctrine\ORM; >> >> trait Timestampable { >> protected $created; >> protected $updated; >> >> <> >> public function prePersist() { >> $this->created = $this->updated = new \DateTime("now"); >> } >> >> <> >> public function preUpdate() { >> $this->updated = new \DateTime("now"); >> } >> } >> >> <> >> class User { >> use Timestampable; >> >> public function prePersist() { >> // Add my custom logic >> } >> } >> >> The implication is that through a simplistic approach, inheriting (or >> overriding) is not clear and I can't figure it out an easy way to >> achieve >> that. >> Now if we go towards calling a function or class constructor like I >> mentioned before, then we could easily build structures like __Inherit, >> __Override, etc. >> > > Here's another example from a Doctrine-using project I built a while > back. (Not the exact code, but the same concept; I've adapted it to > PHP 7 types as well): > > interface Ownable { > public function getOwner() : string; > public function setOwner(string $u); > public function isUnowned() : bool; > } > > trait OwnableTrait { > > /** @ORM\String **/ > private $owner = ''; > > public getOwner() : string { > return $this->owner; > } > > public setOwner(string $u) { > $this->owner = $owner; > } > > public function isUnowned() : bool { > return $this->owner == ''; > } > } > > /** @ORM\Entity */ > class Product implements Ownable { > use OwnableTrait; > > // ... > } > > class Widget extends Product { > // ... > } > > For annotations to work for this use case, reflecting on the > properties of Widget would need to include $owner, and it would need > to include the ORM\String annotation. (True regardless of whether > annotations are array or object based.) > In your example you don't override the property, so you'll able to see attributes of your property. > protected $x; } class Foo { use T; } $r = new ReflectionClass("Foo"); $prop = $r->getProperty("x"); var_dump($prop->getAttributes()); ?> $ sapi/cli/php attr7.php array(1) { ["test"]=> bool(true) } Works fine. Thanks. Dmitry.