Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92629 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63432 invoked from network); 22 Apr 2016 07:07:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Apr 2016 07:07:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 65.55.169.123 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 65.55.169.123 mail-bl2on0123.outbound.protection.outlook.com Received: from [65.55.169.123] ([65.55.169.123:54201] helo=na01-bl2-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 84/AE-14036-3CDC9175 for ; Fri, 22 Apr 2016 03:07:47 -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=5OAK+SElkwuWZEOYAyaPqqOwvsGnolvkpBY83WmTAMU=; b=HUKAy4WWaJ9AnuVsP67woEjuEFc/LNpaBDpRW6IOdU0WBIXiyV0QGoT9oEYgUF5dH4JdJhnqH7T6NLa6A8O0zwzsVk35oC3b5IlUjV+Gwwr4wms2sDRB2yiHfNP7VUFGcj55kNOCLvi7j+TsbT2meq/cjU+AEQ1qekzzQlbZf7U= 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 CY1PR0201MB1787.namprd02.prod.outlook.com (10.163.55.20) with Microsoft SMTP Server (TLS) id 15.1.466.19; Fri, 22 Apr 2016 07:07:42 +0000 To: "guilhermeblanco@gmail.com" References: <571965D1.9020102@zend.com> CC: Dominic Grostate , PHP internals Message-ID: <5719CDB2.90103@zend.com> Date: Fri, 22 Apr 2016 10:07:30 +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: Content-Type: multipart/alternative; boundary="------------010507030504030501080304" X-Originating-IP: [92.62.57.172] X-ClientProxiedBy: AM3PR01CA032.eurprd01.prod.exchangelabs.com (10.141.191.22) To CY1PR0201MB1787.namprd02.prod.outlook.com (10.163.55.20) X-MS-Office365-Filtering-Correlation-Id: 6722d1cf-390a-42f9-f1da-08d36a7ccd2a X-Microsoft-Exchange-Diagnostics: 1;CY1PR0201MB1787;2:nxtFOKqK5sXQwPshF2sjixckL6eANNyU2lS/gKiIBIEvCSxwnI7kRD94iCpJlWIBMyNQ/IxlxgSy3sdNeptjAy+X731944z/5LMFfM+mJtWHIEsDBzRqxJlTOVSV1QFoGDw/beMr86pnz1ivHCStBi5ModL5E/WM9C8SguG7IGrGD1//wx4VBA/T4cCoqwLr;3:EhZofAwqn+4enw2Kzzo6SOibPeBJhZ04NyOQqOtjoOHy33c5XKgphsffSfxzQ0W8ASwJrd42oiuuAa7bJeXZAbUPGgtKJFvQZVKKjMpogks6osBRt4iQfZoLfPtXnsW1;25:r+YlUszJfb9ZlmdLDed/LsbVmwvjfGWsDFc7yjUiHLAphBnfNUS+JrLOI+hp+bdSZo2LEFaMPrUWfk04usRvUPOngVzjpT5KMTkfnkp+GCUn+AvYrw8C7/2+9UIPoy36vNE8epnaq7xufbZoH2hNiHZ+GdOUFCLoeIanrqVxWRK2EVXrE5l8aY0MJEei+Li87DJr45JhyFCLT1TL2XN6VoKfk1ICB7h0IQMtk3GTXyFyAFjHXpr5jC7nSZoaaP+ovrlGzDHpFJCniG3nAVi6gnCtPO3DwBPhxqQwJT74ky9XYxkzoOLpyByFWhwIxxhb7xAyPu0BADCGVsww+wEJGw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0201MB1787; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0201MB1787;20:Zqd29CF+WR5qjU9KjRBXHBrCO2+x+AwNK/KHnJxQs05tp3BbT39U5s9WubQ4YxI+GV4hwKFaqoXyHh5mtj4658jqJQO1H24hppoj9yvrpr/vJmKNt1N6jCS+NNykWU3mJQ/FXfVq0TKzNGaKOgrg8OtZ34uyW9kWwbGyKV93uU9WE1b3Xv0+SMGoNMRIo3TEcjrqVIwTqOLqFRPFQi1E6hvgg/gtVV6+/WZa0kC1hDEdyeqlBG68ZJ80L2prEzo+C8ZxD0FBFvb7q57ni0Iafacph92WZ4irZNnoqJ8/xyWC1cGeU6Ev3PvAxRjjYXj2u/mCS0CDjTuREweuGzDmaTnjAbzFqCZr1mg8GbQcW32XQ1YYbfntk/E/Br+aJ2v9KBqQ6c+XKxw43L+k/rwYd+PtGj2l7tGKieNUcyPhEivc7aamq7/36ktqe0Px2U4zcFn4AxZl1ee9bi3w6bJA5g87/YDFcOy5wBTfofyNi3geloDO0c4BLe/xckgMlmqS;4:XkTCFG8s/BDpufoVXElMZzfUVwLjPYJ4y9Tei1/9DXJ30NHKo0JLqbdaxhZuyCw9Sd5mgI0MrzMES653Zq3IujpOuFIuUOAVGai3Mf3NaEWZ+ozM39V2aHx5L5e+sSJpsaM3BWZDJZItZr08zVsc1aOKdMxW1S2EgqP8KElbhPrX5SZ4k2vXyyoJNAz99U3eysIeOTPUfzBfVdofmTodIiro3BBSSOartlgmRGsWgg8VAXSuEHOhi6UPd7dhRx+6YYzCcch7gDnEdpepeX6z6VcCniKcvTVwGGr1NpJC99RrvI6XCIzYdtScsbZz/rkCZi89FWXr91S5GpMq32gDMqpOTJfZ9WrMv8fU5ZSzX3KLZHioB4vgzmFjs9KIdGcsjdP+5XZCHdu2WaPPWleLJA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(9101521026)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001);SRVR:CY1PR0201MB1787;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0201MB1787; X-Forefront-PRVS: 0920602B08 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(24454002)(377454003)(2501003)(2906002)(93886004)(1096002)(2950100001)(6116002)(33656002)(15975445007)(77096005)(92566002)(512874002)(1730700002)(5004730100002)(270700001)(19617315012)(4326007)(3846002)(64126003)(586003)(83506001)(42186005)(5008740100001)(4001350100001)(16236675004)(189998001)(84326002)(36756003)(19580405001)(19580395003)(1411001)(66066001)(86362001)(5640700001)(76176999)(50986999)(2351001)(81166005)(65956001)(65816999)(54356999)(110136002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0201MB1787;H:tpl2.home;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR0201MB1787;23:HLYpL9ofgVK783E9FN74Tcw0bdww81VPfFBoY3h?= =?us-ascii?Q?fTyjt+Nt1EKzdR36xpAeReoyyVGmkqQFhS49U2wike3r5Uat+cXHdf7/PJOI?= =?us-ascii?Q?qM8W6LWa3u5OibdiPkA8YT9TaAMKxJHAtyTTJeBpX6WNM8T5aFhfwvXprczt?= =?us-ascii?Q?E6TUXVbG8Or8Q/M1Kgh72v08BmgOgG+cB5ixTddw5Gv/gJYyDJBY6xEUgio3?= =?us-ascii?Q?0CJuwm0pWvt8bnUtr7n0THautsumZS3Ob+F0HOTNFwleOONu1EJt4sJsTL+Z?= =?us-ascii?Q?Qz4aMpVumZQdATktlvAysYx9WCQGCNsQaqkeBHQjLXJKklr4q4Q6Ze10KgRV?= =?us-ascii?Q?MTYmyDTd3b0mLjtRHAgWQ/PwXJv6FGZ/9oqWY+qQ/BXnkfWYBnRI3KllS2rV?= =?us-ascii?Q?I3JNrBPZTj5D18kFfcLB6k4CSyWUs27vyuCIYdmZHVbxtaeak03gBma/Ds9L?= =?us-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eQ7IzRd0TPubZfBPbWkI9L4YEJn0npLSO+0ExKs3fMLKPk1sbhoNFP/UR/t8cbCwI9ViUo0Ie2Az5R8IvN1zkXA;24:KwbiPIZ8OzVI3sZuEwIsc/QbplXPTjMlSkgmSbB/JR4HDCE6aiblre6h6GydW1msHlZIQ+dDlJMyYhUyi/qfYdWW+PSFZOztqODtasDihHM=;7:An53g4Kx9dwCsIhMy6geCcufIhP8xkSU2D6H7G7vhpUNqC8IVuWXrV7zaAbLcZccmEsSE0REAu/r08U5Y9OL91dlpLhoo89eJfesSvZ/vAbzvyDygLcBuk3SZ8WdgYOqoPFtUdAi8wOwXHENzA3fhg4hr9WdeVDPg3rQwoxyBVQ4BkMB/nqoksD8wq8H5O8bsoWEt8/XouWwa3O8A2NUW6Q5hs2k/L5x96fSd/MjMcs= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2016 07:07:42.7664 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0201MB1787 Subject: Re: [PHP-DEV] [RFC] PHP Attributes From: dmitry@zend.com (Dmitry Stogov) --------------010507030504030501080304 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit On 04/22/2016 04:05 AM, guilhermeblanco@gmail.com wrote: > Hi Dmitry, > > As a previous suggester of metadata information built-in into PHP, and > also one of developers of the most used metadata library written in > PHP, I understand this feature implementation requires several design > decisions and also a good understanding of specific situations users > may require. > > While I am a strong supporter of a more robust solution, this is > already a good start. > A few things I'd like to ask for my own understanding and also > suggestions too: > > 1- I understand you took a minimalistic approach towards a "dumb" > implementation for attributes (when I mean "dumb", the idea here is > towards a non-OO approach). Can you explain your motivations towards > this approach? > > I see two distinct approaches of implementation for this feature. Both > of them have some common demands, like lazy initialization of > metadata. Here they are: > > - Simplistic approach, which lets consumers of the feature do all the > work related to validation, assertion of valid keys, values, etc > This does not invalidate the ability to leverage of some features that > a more robust implementation demands. > > - Robust approach: language takes the burden of instantiating complex > structures, validating, assertion of valid keys, values, if this > complex structure is allowed to be instantiated in that given class, > method, etc. I didn't exactly understand what do you suggest. If you are talking about Attribute objects initialization during compilation - this is just not possible from implementation point of view. Now attributes may be stored in opcache SHM and relive request boundary. Objects can't relive requests. > > 1- Your approach is basically defining an array. Could you explain > your line of thinking on why you didn't consider a syntax like the one > below? > > <["key" => "value"]> > class Foo {} I didn't try to invite new syntax. Just completely took it from HHVM. > > 2- I see that you added support over functions, classes, constants and > properties. According to the RFC, getAttributes() was added over > ReflectionFunction. Is there a reason why support was not added to > methods (ReflectionMethod extends ReflectionFunctionAbstract, which > was not mentioned on RFC)? Any reason to not support it in > function/method parameters? ReflectionMethod is a child of ReflectinFunction, so it's supported. Attributes are allowed for the same entities as doc-comments (they are not allowed for parameters) > > 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. > > 4- I understand that a more robust attribute solution would be > required to achieve this, but one of the biggest advantages of AOP is > the ability to perform custom logic before, after or around... > However, I don't know if any kind of triggers came in your head or are > planned as a future RFC. > Let me highlight one example: Every time a class, property or method > is called that is annotated as <>, I would like to issue > an E_USER_DEPRECATED warning. A trigger-like solution would be > required. Did this concept came to your mind? This is not a subject of this RFC. Attributes provides a storage for metadata, but don't define how to use them. Especially, for your use-case: 1) it's possible to create preprocessor that embeds corresponding trigger_error() call 2) it's possible to write a PHP extension that plugs-into compiler chain and checks <> attribute for each compiles function, then sets ZEND_ACC_DEPRECATED flag 3) It's also possible to override DO_FCALL opcodes and perform checks there (this is inefficient) Thanks. Dmitry. > > > > Regards, > > On Thu, Apr 21, 2016 at 7:44 PM, Dmitry Stogov > wrote: > > > > On 04/22/2016 02:16 AM, Dominic Grostate wrote: > > > This is amazing. It would actually allow us to implement our > automated assertions ourselves, as opposed to requiring it > within the language. > > this was the idea - to give a good tool instead of implementing > every possible use-case in the language. > > Could it also support references? > > <> > function foo($a) { > > } > > yes. "&$a" is a valid PHP expression. > > If you plan to use this, I would appreciate, if you to build the > patched PHP and try it. > The early we find problems the better feature we will get at the end. > > Thanks. Dmitry. > > > On 21 Apr 2016 10:13 p.m., "Dmitry Stogov" >> wrote: > > Hi, > > > I would like to present an RFC proposing support for native > annotation. > > The naming, syntax and behavior are mostly influenced by HHVM > Hack, but not exactly the same. > > The most interesting difference is an ability to use > arbitrary PHP > expressions as attribute values. > > These expressions are not evaluated, but stored as > Abstract Syntax > Trees, and later may be accessed (node by node) in PHP > extensions, > preprocessors and PHP scripts their selves. I think this > ability > may be useful for "Design By Contract", other formal > verification > systems, Aspect Oriented Programming, etc > > > https://wiki.php.net/rfc/attributes > > > Note that this approach is going to be native, in contrast to > doc-comment approach that uses not well defined syntax, > and even > not parsed by PHP itself. > > > Additional ideas, endorsement and criticism are welcome. > > > Thanks. Dmitry. > > > > > > -- > Guilherme Blanco > Lead Architect at E-Block --------------010507030504030501080304--