Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92734 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49409 invoked from network); 25 Apr 2016 15:21:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Apr 2016 15:21:21 -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 157.56.110.108 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 157.56.110.108 mail-bn1bn0108.outbound.protection.outlook.com Received: from [157.56.110.108] ([157.56.110.108:43936] helo=na01-bn1-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 83/D8-00233-EE53E175 for ; Mon, 25 Apr 2016 11:21:19 -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=tLy7Qe01JhGgHhMxNliq9a2S730oVTL+5v2YA5uFum8=; b=sbuqstgZIso+4tFx5NfaH9ZD3zOMHaZUBhrdfAx5c0/0U8cvqpNGe0p72M6pB7DNIov81pgu5mc2EmBoZe80VNlGD90tc+3Jwxkl85WTAejHJcCt3F8g6wMr2/hRnrxjPKgZD3jKBE87RPT2ACV7r+BAh0lydL2KWJaW3DeZutA= 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 BLUPR0201MB1777.namprd02.prod.outlook.com (10.162.239.11) with Microsoft SMTP Server (TLS) id 15.1.477.8; Mon, 25 Apr 2016 15:21:13 +0000 To: "guilhermeblanco@gmail.com" References: <571965D1.9020102@zend.com> <5719CDB2.90103@zend.com> <571DCA6A.2070803@zend.com> CC: Dominic Grostate , PHP internals Message-ID: <571E35D8.8080504@zend.com> Date: Mon, 25 Apr 2016 18:20:56 +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="------------010700020904020102090900" X-Originating-IP: [92.62.57.172] X-ClientProxiedBy: HE1PR03CA0004.eurprd03.prod.outlook.com (10.163.170.142) To BLUPR0201MB1777.namprd02.prod.outlook.com (10.162.239.11) X-MS-Office365-Filtering-Correlation-Id: 95ae0b95-ec6e-4c96-508b-08d36d1d3dcc X-Microsoft-Exchange-Diagnostics: 1;BLUPR0201MB1777;2:7aPfA9I7LW1ee1/nDcYwKRBfO5yefUIoeXAc+/DZimZ88pQ9SeKKCAZJHK+Wl6SNLcN4anYST6WGstyG1aXKG26bBumlQv728+WcCsF5s3CHtlRsFpyF/ufCyZvONUuJrXaZ0MB4+QIWsfnT6NOuZ/FMtL2eqYUP41/P7U6c8UKP+MSzvolMBgdq+M86mG0E;3:h5dlUg0G9JxiYDHOI7+/bwXiVotda91dV+CR8Ehsgdymg747pR+hOJrbhzmm7YAwtIiNaVCJM7eY19WLDtXiyJ+0F4vTINfZo9sVDCuARr7PqjHIRlM/2VTdpFdxwaWV X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0201MB1777; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR0201MB1777;25:wlFJGczXsE2meAx2TlnU9le8KJuajUZTKoOBf1Y?= =?us-ascii?Q?LcdcYRwUSzwRntLPi8kjIs9BE4abrxQzWVtfXF5bS4bppbLppFw4O82nONHM?= =?us-ascii?Q?+niJONqks4J4/21bpknfj71eU7RTMCqnLFelUWSUZaNMCWpk8GWJpmB2q+TG?= =?us-ascii?Q?rKm3cZ0monIJPZVgR7FIyMWBuQyesRKYNn/RqXoADmJixuDU8OGcB6grjHb7?= =?us-ascii?Q?Dge8Pkx4RjwszqNqQtfOd7v1btvsfGo66EfzNK09iIqKQ1GfKn9ruR6xeZYz?= =?us-ascii?Q?NizMfilCdO+Nn6VuDVxKqMD1E3K1UPktzaWjCVww3Vji2P6VHU678DWgV3LV?= =?us-ascii?Q?ZnlouvipXu7j0+tZc8XallYRQeU7EkKxiD/pvXcPPNFk8GHym1EmY5hlEBfm?= =?us-ascii?Q?+pm3Mfmfbm0yJun+pFBP1uhqgdec79hrQ7b7wrvKjAskahdV38ebCH26Iufb?= =?us-ascii?Q?rVDzeN0KgmFWhbaqRUyE5n03FyZNptjS1doMIP1lnGjYxOteqqisrUxQrqCU?= =?us-ascii?Q?25tfGfopFjINvR8SfeQxIXTLaECMZZH9XgpDFT2/RckYeNLP6ffD4PelqFyq?= =?us-ascii?Q?Khqt4aA2NrfCSyuS+GQ+wUFoAJdxg8AhGvg7LjrPxVFSOseV2oMr2Isiuf2U?= =?us-ascii?Q?rgBV7U42ujrhM3CrLh/5qVrIv0Jv6xxdi5e165wqGbzA3IpYXwg8FZ0rWggI?= =?us-ascii?Q?Y5o1EMgK84CUMWdVZAXGxareweZ1Vj95vC5oBZ852vA0xRi7zjSS5xJmkdAN?= =?us-ascii?Q?S7ZhGr0F5nDZTIqUW55YdH1J9fVn+BaUDoLgkRLpuJKlEbwBJMDskAt7AVvW?= =?us-ascii?Q?+X4fEAag0GrZ1rH50u24TAu03c1VlETqjNMWfd6XwedB8yP1FPgyZ+03k0jM?= =?us-ascii?Q?XENydfjiK+1dPconIJDblfNDTvwa5EyNdPEsO1jzmgK0SvdtHJHPesCu1ZVu?= =?us-ascii?Q?A8Yv+Av0bETjCMT9rgENJ0NA+dTMzKaINtTPowweBvw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR0201MB1777;20:5QQ8jE/KKONiLg+8tQk2uEonsKeCSukiIF1JGiFjkNWAjvS09hkqHrXsj+Uubn9wWtxDXcT4laIWTVgvxQ70SRLWaADSNXubWs1+ZHiY1lZitHLw3M5JkthkDIHIiGnXi/NLb3iQYWYjxwor4eyJVgfzgW7bE7eBdMgvr1gl5u867cLLLrGYmOLUikZJQVeo2J71eEAgPnaryaDSbAth+WReds+YuRZvUzZPdaZjYKKNX/WJiDhg4a284mldQHfp86d7furmziSX/apcD9jyjm6Cxb11jvEiOnu1P9/6hN8484Rf7r9lixkdHQLmFsAJhXH/jcoTeOcTVVEdTyf+XskVuioUJuLzYpPnY+VjGvwfRrq42W5SmyqTrAbakDoG3Gc+8BueX5qQxm5Syl6wiDlF26Fg8oZuN5Bu5OiJvUlFBXwpTOSWdTKOsEA+IzCQYmXZ6kgjCQrESficiraksFe/wC9z66xqcoygLBx6AT0tTZH8ONvottLJK5VKivpn;4:FWs7eZPlS1+1Ydz67nGwd4kU+KJMMluY0j57mKh1OnAwor/8pFLloYd8iyuLtoy33reCSyTMmO1XQaMhAYFZBo7OuDcX5obay/fMb+6RAx31dvE2AW8XOSQnU7vjNjzw2btMU/Qz9RX67jgIU5QdwUFy55ewIE47z8QQOFRb5djKb7yyT1FDQ5P/aazJvF0FjU5OfbdetkvZflpT95aulU0ChvrkWne3DR0+ViNZa/Bc+UaF8rzxbRR/d8dyggslROvAjViwLr/Cl3iDiVI+JpTBgeR8gGwDjozIr9LbI2djCzl2Qi2A7fE1kaVFpECatAQOHOTMDptuWW58MBWhvztfCZoafJ8z+Ke3s32BgpUIy2ONOCGpphKAGm+URJUk/X8x62giCkVMbiogE7lsFA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(9101521026)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001);SRVR:BLUPR0201MB1777;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0201MB1777; X-Forefront-PRVS: 0923977CCA X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(24454002)(377454003)(15975445007)(84326002)(6116002)(93886004)(4326007)(77096005)(1730700002)(3846002)(64126003)(189998001)(270700001)(5004730100002)(1096002)(5008740100001)(1411001)(110136002)(86362001)(50986999)(2950100001)(76176999)(87266999)(54356999)(65816999)(561944003)(92566002)(65806001)(15395725005)(2501003)(66066001)(65956001)(512874002)(36756003)(16236675004)(2351001)(80316001)(19580395003)(19580405001)(2906002)(83506001)(42186005)(19617315012)(81166005)(33656002)(586003)(5640700001)(559001)(579004);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR0201MB1777;H:tpl2.home;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR0201MB1777;23:lRSkWYQdgTOYGAEjUbMl1UMEWDbTMd1f1Pv7w93?= =?us-ascii?Q?d74gMnySiOt231gkLrVJSgbRRyX1iLutjeMffYpivjRNSfe2juGpLdzfdmBy?= =?us-ascii?Q?HMdbJJyD1V0hzVqoVFE5kbgqx6mmQ3BBW+hfMglsWyPcwq57Ly860eqEV6S+?= =?us-ascii?Q?U2+uAAj06pp671AQRX9JbXkXRUVK32nlAIkr4BDvmm039OhWCP30vtIujQNR?= =?us-ascii?Q?9BzxAxlkrYBSdxr6CU9LB5HX7vUXDFVWtJonowzq0IBTXBUcujBTXOqYmOt6?= =?us-ascii?Q?KAVyxbQiASwpORZrg1uJ5kmJRpT9Ibls9AGWD/iHExA4aYwySf9FUUgKggar?= =?us-ascii?Q?w752LAVGbW0tc5voFcNYhQQ+0D57172XVWQLokhSTAJvdWdEIu3F7Cl3s6bc?= =?us-ascii?Q?KZlEV1F+Gwv5WiLAyC4MG6TyU1XMfm8hUAF9X9yZNNEIIiH+3pZfkypAVwh6?= =?us-ascii?Q?ZrmlsUaM27mzRZtp9110vxev/k0Vbzqhki5XbDVVVLsaw8szMQrqBqLXPASl?= =?us-ascii?Q?WeVEY24Xioa0LZQJFxi78lGubIsaby68/UtlGjf1RDEpUkeGWYZr4s2AYGgZ?= =?us-ascii?Q?gFEycS9UW264X9noJKJtslXuGUi53kBCGTGr4ZFKSZ79DcT2N8G9ufNsgNmG?= =?us-ascii?Q?yuq/4WwF/I5ZQpRITEWeV+xVscD3n1QM3+N00Q37vT8LoElLPmyBEVH9p0DM?= =?us-ascii?Q?4zpH1sowMNX9VGy7LHGezXdRGFtBWt07Oz7rWCfIWBQOM8gbRvSHyzEOfR9Y?= =?us-ascii?Q?r0ObAdIfcYIr2TzMH2kLxH9YcIKFOl3ZW+nx+iDWy9npM2vljOrMFEJhzT5t?= =?us-ascii?Q?kdiRknFo0GErzb58pxaUYn4qNmzEZvL4L1gamPPMpBPnc4Rb13NB44v0r8kw?= =?us-ascii?Q?UNOcsQ/Rw9Hhds5G3S7DLdQ7FXc8ONDde4Yq3X9lqIjmWCtoyQeAe7AqGtA0?= =?us-ascii?Q?K+ahr5PHJ0kAdC7SK7tsQ8g19LkrFUGcxOAla4ckWXxzbxsAPG/nTmpfZYot?= =?us-ascii?Q?eC3vtTTYQyLp68l0pWt/cm1n5Pq1YG2www1SV3znrQ7D/AknK3rqTaM0L6Kt?= =?us-ascii?Q?V2g/3ZljqhemzUcAygwi0aRLl/p5YjVw0XcgWf7Ho3SVef3jLB5UveoNKut7?= =?us-ascii?Q?r13pRL0gWqlZ/TSvFDgbN+iFYliVD0S9nGjNBOu5XLU17FPXQv+aQPQ1YIJH?= =?us-ascii?Q?IFpm8riKlMK8lXCrHeNmXKOSSgQYAcpy+IB7eMSPF/6dVrd3Y+UDCYBHDQO7?= =?us-ascii?Q?/I++2DKU1yuXiTwwnFgo4qUJwVmMzeK1dUjgub4niwGZc8G46/djgjOEypYQ?= =?us-ascii?Q?WLQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR0201MB1777;5:j7tDG4wFrAO6LaR6CzGsuhXpaNV5WefbOvOVdeJoF0v+7YQfQmliAludfGWOC1gdcaexWmo9mRBSljUXQoWfLxaTp7EXo1yNOTzrLxYcyqoMnzGV3Qlwmv0RJW2yClAMvNIe+RMt4v2qxZMYX9kF4w==;24:xHO3+nafOld+H9kp4AqBdWPvyJyUELatzL5gmQ3VhiDHNrYVsFNiPTkQQFP5+Nk/386DVVQLrczi9+zKe1LE0eSLEKkrSECyG+YcrHtSafo=;7:DBoJiGVAguHMbUWTIRk0nu1w4J9oA6u5W+CBU3nyUnwaldyIMceqa8DIQh2tgq0PgCmp9RnmIepOEXQ7yz1VYY1tW+dQQ14UMr0nqiF4rX0JZp5kN1/k9YT3xBgVxNpykt3hfks6ZgN+qkfagPtsyETy8l3djU05H0LNzhmIcu1g7zqi7Sfo5ONNmZKTTR07 SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2016 15:21:13.6400 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0201MB1777 Subject: Re: [PHP-DEV] [RFC] PHP Attributes From: dmitry@zend.com (Dmitry Stogov) --------------010700020904020102090900 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit On 04/25/2016 05:11 PM, guilhermeblanco@gmail.com wrote: > > > On Mon, Apr 25, 2016 at 3:42 AM, Dmitry Stogov > wrote: > > > > On 04/22/2016 06:39 PM, guilhermeblanco@gmail.com > wrote: >> >> On Fri, Apr 22, 2016 at 3:07 AM, Dmitry Stogov > > wrote: >> >> >> >> 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. >> >> >> >> I know that object instances are not cross-requests. Explicitly, >> I mentioned that both approaches require lazy-initialization >> (which means, whenever you call getAttributes() or getAttribute()). >> >> What I mentioning is that your approach is basically a new >> key/value syntax that are used specifically for Attributes. We >> could easily turn this into a more robust approach if instead of >> defining key/value pairs, we instantiate objects or call >> functions. You already demonstrated interest to support >> <> reusing the imports (which is our biggest headache >> in Doctrine Annotations), so why not issue constructor or >> function calls there? That would simplify the work needed for >> consumers and also add room for later improvements. >> So basically in this example: >> >> use Doctrine\ORM; >> >> <> >> class User {} >> >> $reflClass = new \ReflectionClass("User"); >> var_dump($reflClass->getAttributes()); >> >> We'd be changing from this: >> >> array(1) { >> ["Doctrine\ORM\Entity"]=> >> array(1) { >> [0]=> >> string(4) "user" >> } >> } >> >> Into this: >> >> array(1) { >> ["Doctrine\ORM\Entity"]=> >> object(Doctrine\ORM\Entity)#1 (1) { >> ["tableName"]=> >> string(4) "user" >> } >> } > > As I showed already, it's very easy to do this transformation at > higher layer. > > $reflClass = new \ReflectionClass("User"); > $attributes = $reflClass->getAttributes() > foreach ($attributes as $key => &$val) { > $val = new $key(...$val); > } > var_dump($attributes); > > Construction objects directly in Reflection*::getAttributes() > method, doesn't make significant benefits and even makes limitation. > > > Sorry, but I don't see how limitations are added. If you call a > function, static method or constructor, you actually add whole new > level of possibilities, and I fail to see which limitations are added. > Could you provide me one? For example, I like to check an attribute existence, and I don't need to construct any objects. > > Calling the function/constructor/static method, not only helps to > better segregate userland code, but it also adds subsequents > extensibility. I can highlight examples: > > - Support for Inheritance and overrides, through @Inherit, @Override, > etc. While you might not see how it could be used now, other > developers might be weirdly creative. > - Targeting of annotations, such as limiting its scope to be only > class, method or property. We use this extensively in Doctrine, where > you cannot define Doctrine\ODM\Entity over a property. > - Separating what can be considered as an annotation and what cannot. > Built-in @Annotation as a marker would differentiate that I can do > call Doctrine\ORM\Entity and not Doctrine\ORM\UnitOfWork. > - Make it easier to support an AOP extension, where it could detect > annotations being used and override DO_FCALL to call before, after or > around through the implementation of interfaces. > - If we ever decide to support named parameters, taking advantage of > that would become natural, like: < "user")>> See a new example at https://wiki.php.net/rfc/attributes#use_cases It's already works. I don't see any reason to rewrite that few PHP lines in C. > > > >> >> >>> >>> 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. >> >> >> My idea was based on your current proposal, which is basically a >> way to define key/value pairs. >> If you decide to go minimalistic, that is probably my best line >> of thinking. >> >> >> >>> >>> 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) >> >> >> I was asking if there was a purpose to not support Attributes >> over ReflectionParameter. Example: >> >> class Foo { >> public function bar(<> Bar $bar) : bool { >> // ... >> } >> } >> >> $reflClass = new \ReflectionClas("Foo"); >> $reflMethod = $reflClass->getMethod("bar"); >> $reflParameter = $reflMethod->getParameters()[0]; >> >> var_dump($reflParameter->getAttributes()); > > I understood, we may add this ability later. > > > I'd say we should add this from day one. > A quick use case that comes to my mind are parameters conversion that > happens in Symfony2 through their "extra" bundle (doc: > http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html > ). In a controller action (it's a class method), you have the ability > to convert the Request object into something else that makes more > sense for you. Example: > > class UserController extends Controller { > public function viewAction(<> > User $user = null) { > if ($user === null) { > throw new NotFoundException("User not found"); > } > > return ["me" => $this->getUser(), "user" => $user]; > } > } I'll take a look into this, but you see, I'm not very interested in wasting time implementing particular low-level details while the whole idea is not accepted yet. > >> >> >>> >>> 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. > Very questionable. If you redefine property, it shouldn't inherit > attributes. > > > 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. > > >> 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. > It's definitely, not clear when attribute inheritance make sense > and when completely not. For example, if we mark some method to be > JIT-ed, it doesn't mean that we like to JIT methods of all > children. So, I prefer not to do inheritance at all. The higher > layers may emulate "inheritance" of some attributes their selves > (like you do this with doc-comments). > > > 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. Thanks. Dmitry. > > > >> >> >>> >>> 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) >> >> >> With this simplistic approach, I agree there's 0 value into >> considering this. >> However, taking a more robust approach would potentially open >> this possibility through a simpler extension. > > You saw, Sara named even this proposed solution a bit over-designed. > it make no sense to implement all functionality at language level. > Actually, keeping simple base interface, opens doors for more > use-cases. > > Thanks. Dmitry. > > >> >> 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 >> >> >> >> >> -- >> Guilherme Blanco >> Lead Architect at E-Block > > > > > -- > Guilherme Blanco > Lead Architect at E-Block --------------010700020904020102090900--