Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93084 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2855 invoked from network); 5 May 2016 07:34:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 May 2016 07:34:42 -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 157.56.111.102 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 157.56.111.102 mail-bn1bbn0102.outbound.protection.outlook.com Received: from [157.56.111.102] ([157.56.111.102:8850] helo=na01-bn1-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 89/89-16256-F87FA275 for ; Thu, 05 May 2016 03:34:42 -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=Py5mrUjZXm9pOPMoS65/+CiOWCtrOezMdKOco7ssfD8=; b=CjPgU8Sed74ASJVhJTNeXhHHuDFzktPeDquFjUstcPxaNq8XK4ohiHtfxgonY5uUz/h2Hsh/Prhe3QkwDIb7wQmvOI+GJnDYs/bj3QbfgFPpYflnNlMR2xVirq2fTa3jhy/GjuN6OwcRIAlXT0dEY8bZSmYI75/PIQqsKqSJnFY= 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 CY1PR0201MB1788.namprd02.prod.outlook.com (10.163.55.21) with Microsoft SMTP Server (TLS) id 15.1.485.9; Thu, 5 May 2016 07:34:33 +0000 To: Alexander Lisachenko , Stanislav Malyshev References: <5723F2AE.2020806@garfieldtech.com> <8a7d1e8a-1e9e-0bbd-912a-21201638b989@gmail.com> CC: Larry Garfield , PHP internals Message-ID: <7f04c375-9f6f-f107-fe5a-a39c19bcd05c@zend.com> Date: Thu, 5 May 2016 10:34:21 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------68452C4A337EF18E440B234E" X-Originating-IP: [92.62.57.172] X-ClientProxiedBy: AM4PR01CA0015.eurprd01.prod.exchangelabs.com (10.164.74.153) To CY1PR0201MB1788.namprd02.prod.outlook.com (10.163.55.21) X-MS-Office365-Filtering-Correlation-Id: ee4ca39a-a4b2-4b30-cb01-08d374b7b549 X-Microsoft-Exchange-Diagnostics: 1;CY1PR0201MB1788;2:jMIWKLsAduOsQC3xy9jwz8rrxI32eZQ/A4mKcJJxZHDIiNR6QRQzn5UkZCh+Wlvw6+NVa1kvwamUvYaV2pDvFZm1vhveYLnjlW6KlbXW+jM+e0VEYCiIjlU19Ga4lLlaFOGy3NgWeYzD2dAs4ohgT+MsKSI2JG+RPmTRpQDAaZdZzYKqKOMWFnlHEkbhNxX+;3:qo7kqBG2q94Jj05KMnd2ard+OXbOkdeDq72jLBMhgI30tg5Eodcr8vVgHJlp8HhEgLJWmm2OMgpCne/5CPEtw8728tc08NpHjimKCaIEwXi9PMKpqBTMFAbVQXEkNq3h;25:7PRP3UW9JtLAIbVxr0erNOirSLBVjAB0ZZq3pUU0lvi4Xyr+E2mwGws86ttu5DO+P3YalUhydpTBBP3Ia4/usaRFlKrRRE+ZBUu0xEcKvQFQcLknbKL3GEgj9nHTIss/C27KU28d0gnZfePuFjnnx6S1kKGr7SUPhplYBhAZR6IdzKmZqMeDoWJspTITySFXQQ9Fkf3bEBcI1kZbqfq4pEg6LURAm3swfk4MfY8YjjxQ7LbhDCOp8JGnRAZ/AA9Cc8ejCqj/4bAFn0D7jOo2tfUjkXLNw1c3yQGTTn3Hup65X/Sw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9KNso8gTNZQKrphGUFDdS0W1j2Mzfk5zR3ocEyiS3wRpihEIqWyyq2yWIw/4atJGKw/Q== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(9101521098)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046);SRVR:CY1PR0201MB1788;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0201MB1788; X-Forefront-PRVS: 0933E9FD8D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(24454002)(377454003)(377424004)(42186005)(92566002)(586003)(2950100001)(6116002)(3846002)(31696002)(33646002)(5001770100001)(4001350100001)(93886004)(77096005)(270700001)(64126003)(19580395003)(36756003)(86362001)(2906002)(512874002)(5008740100001)(31686004)(81166005)(16236675004)(76176999)(65806001)(54356999)(50986999)(65956001)(66066001)(84326002)(83506001)(189998001)(4326007)(5004730100002)(19580405001)(65826006);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0201MB1788;H:tpl2.home;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR0201MB1788;23:egD8hfeNHYw6r2c1U0UPuBJmOCOzz2IEsGgoOpU?= =?us-ascii?Q?nodUNngl8IP5exr/Ba64MRSkbRlCZjIuwerOJYpd5smhoGxHzoblXTAShvOf?= =?us-ascii?Q?uzMsujRAIVXjwsxwzW+tjSMfIFs0uzk62trKM2r2d6x4MlXQYjtHVSwKoWxj?= =?us-ascii?Q?9Di8jhgYFUQoRE6b4NhC/sY9jG35Cu5AwZonoD1MTE3x/jPm4rtPkjFnmtIW?= =?us-ascii?Q?X4kFGh7VVlHP8t1Sp+lHX28pEPKaSxdyoh/Uxw1bCFKU2Xs8D8KJC6U0chjY?= =?us-ascii?Q?BLoqZGyuDMIGBJwh5T0gGMrsIg6FWcuhMVbJgaCMH9Z8w6hTBoSj+43W0daY?= =?us-ascii?Q?XwlW+ksG09JB/dhTsLWlfCeNselvulA9/73QOa0Qh5DtFZIX9McRnz470DzB?= =?us-ascii?Q?O+54lesF1KP5tzopceJokdVJcav9j4gkGRlxfXRWjPJpJGBLjFfaNSZbhKaT?= =?us-ascii?Q?mk2lmaWp5CBDO71BqRYRVhiik0CZ0HZ1aSdh1/J+GJjqwgEi/Rgo6YGRQiXY?= =?us-ascii?Q?+NmQ4Gv6ssyOt9GYxMIcME+MMv02hERlplc7aWe17z8TUnNl91ga/seSNlf7?= =?us-ascii?Q?yoRA8D9/hqS62ndxwbIOvXVm9UCOGpt/hJAtP5P2G5B4gv8bAOefpEZKSjgW?= =?us-ascii?Q?WteUkTh2hQiZLJV2AphfdEffuSNo2Yf/hGsv789qhH0RS+csPDpZeAet1hu7?= =?us-ascii?Q?qVMMxRAPrCJSvbhWphngDrOSzlBBKtiD3GBzq4uKLXI8dzSO2tK+plPc5pGL?= =?us-ascii?Q?OTVP9JIMAR4o4ThngG12Okzxy5joZgWvEWwyzpQt3RemBUFlRKol01joMW8u?= =?us-ascii?Q?DsGoBQJwTT7WvQn7MVnPIax9qA3F4qVqdZpne+znXFLzrXONh4caVT0xCkYk?= =?us-ascii?Q?AOtOZfNmsnyboEfIZ3UtSvs5snUeCkQtniTzR6JK1M6vrMNhPwVAF/KugjCj?= =?us-ascii?Q?0XrkKoXp0BFQiRV/QWPVPbVZ3M6FBa9bjeybrLcZ/FoL8ktah1OCyVZDS3kP?= =?us-ascii?Q?2S03NCa589f2oSWz7VCSJ/2zAl+Xym3dDtFWqZPnxr+Z/n2oDk9KCKDhUp2D?= =?us-ascii?Q?pqcJhaE3VgufindHVN9UEFyJ+TEAxCDGov5XZ0k8pNaFNAbmKqA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR0201MB1788;5:hlSCAXIjoVIaS+DoM39eXehSy4HVa5/iw+bRY3YCcOYjN6ZlTF81cPybQGwYH1FfZDZ0wp1xzYBnFzWv8axEM9dwhoouK2lCkHyhopr3sLksO+K6PieOZKrkt1PdVjZOjsWj2AZW077ceQTZT0eBfw==;24:5p7hAY4s9f2tkAPjfKdpBrOqHRvIik7kHRU0g1lhvb4/6EfW/lwk0SiWyveLN4f4DcgCfHg0U7wZFCJ2ljOmOwMGOgGS+VKCG47VkfT3bug=;7:Jsn1IaLD0FQGRiDXC4H5WkkH37vpgC0U7D4MJe1MoaFO4KH/ctbROHzbVqRwIdvNTurxhoIJze3OVT6DQesq4GeQtzm3MpVhgNjYMbxt0fN8WZC+t4GgJreSGoi7L816stpNuHt38Db2dhvLO74PnPtrjr++M6bu0f196uI76W+2lVk991bppOQZpvr5Mr1b SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2016 07:34:33.7783 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0201MB1788 Subject: Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal From: dmitry@zend.com (Dmitry Stogov) --------------68452C4A337EF18E440B234E Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit On 05/05/2016 10:24 AM, Alexander Lisachenko wrote: > Hello, internals! > > > 2016-05-05 9:48 GMT+03:00 Stanislav Malyshev >: > > Maybe that's what we want to have here - freedom for everybody to > invent > their own languages - but I fear the danger of fragmentation here and > also people implementing tons of slightly different incompatible > parsers > for ASTs that are generated. We'd have Drupal attributes and Symphony > attributes and Doctrine attributes and Zend attributes and so on, and > each of them would have different semantics. Not sure this would be > good. But maybe it avoids arguing about the syntax now. > > > AST for attributes is a nice thing for abstracting from the concrete > details about how attribute is handling by the concrete > implementation. I can see a lot of common with class autoloading - > earlier there were a lot of custom loaders, thanks to > spl_autoload_register() that defines a stack of callbacks responsible > for loading classes by their names. And everyone uses custom class > loader, but later PSR-0 and PSR-4 were described and adopted in > composer, so now we have one general tool for that. What if we select > the same direction with the stack of callback? > > How it should work: PHP engine stores all attributes in the plain AST > without any transformations. This data should be accessible via > ReflectionXXX->getAttributes(ReflectionAttribute::RETURN_AST). After > that userland library can register a hook as attribute loader: e.g > ReflectionAttribute::registerProcessor(SomeHandler::class, $isPrepend > = true) or spl_attribute_handler_register(SomeProcessor::class, > $isPrepend = true) > > Each processor is a class with two methods: > > interface AttributeProcessorInterface { > public function supports(Php\Ast\Node $attributeNode) : boolean; > /** @return mixed */ > public function process(Php\Ast\Node $attributeNode); > } > > After that if we call > ReflectionXXX->getAttributes(ReflectionAttribute::RETURN_VALUE) PHP > engine will call each processor and asks it if it supports this AST > node. If processor supports this node, then engine call it's > process($attributeNode) method, returning the result as a result, > otherwise looks for another processor. If no processors can handle > this AST then PHP can throw an exception about with information about > missing processors for attributes. > > I think this way can give a good start point with possibility to > standardize handling of attributes in the future. From the PHP engine > side, all attributes are AST nodes that can be processed later on the > userland side. > Something like this may be implemented, but it should be well designed and approved first. I'm not sure if this functionality should be especially implemented as part of Reflection API (this is easily implementable in PHP itself). But in any case, this requires the base attribute functionality proposed in RFC (or some other). Thanks. Dmitry. --------------68452C4A337EF18E440B234E--