Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92719 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11638 invoked from network); 25 Apr 2016 09:07:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Apr 2016 09:07:16 -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.111.139 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 157.56.111.139 mail-bn1bon0139.outbound.protection.outlook.com Received: from [157.56.111.139] ([157.56.111.139:29040] helo=na01-bn1-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 08/62-00233-24EDD175 for ; Mon, 25 Apr 2016 05:07:15 -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=0uOF52nKT4JPQuMzdMrvZjf1IzJDKk8jzlC2jAG60JM=; b=TD+DURE/8i8D/gZKKpO0tSrejVpUFs3YSlnzmt92dHMqDd2klY53kYxcx2Ykd3ywNa9O3BiSK/pTK3PU/K7BwE7c81B28MzhzMpKSWFKtXbN7Pi7Af4OR7C6l8U2mk8p4iB1kulfBc6ZSOwJL6ourwdWKn0m4TpVBL23iVu5DsA= 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 BY2PR0201MB1781.namprd02.prod.outlook.com (10.163.72.23) with Microsoft SMTP Server (TLS) id 15.1.466.19; Mon, 25 Apr 2016 09:07:10 +0000 To: Thomas Bley , References: <20160423230908.BD6F21A800F6@dd1730.kasserver.com> Message-ID: <571DDE2B.6080903@zend.com> Date: Mon, 25 Apr 2016 12:06:51 +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: <20160423230908.BD6F21A800F6@dd1730.kasserver.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [92.62.57.172] X-ClientProxiedBy: HE1PR03CA0001.eurprd03.prod.outlook.com (10.163.170.139) To BY2PR0201MB1781.namprd02.prod.outlook.com (10.163.72.23) X-MS-Office365-Filtering-Correlation-Id: e3dc776d-74cd-4163-92ca-08d36ce8fc7d X-Microsoft-Exchange-Diagnostics: 1;BY2PR0201MB1781;2:vLrOzMko0fqu1UsyFIhO6eSivSLVJ3jlBGM4r/lRFnsnldEI6p5yhPBkKVNXVbD7SJbIYmacxquahBGLO0KGE0pjnCd5eftuNj3LHCpjkFXnoeAuLQ7f1ZenVAeNNyb2we6CqpLxKfc6oRBuP7a+97zyBRftemhMEOfxHQrAvPq8bph988bOuy3cU+demPwE;3:uIBISCjOUH/LwEkfK+DBohInNmgsE+ho2WXaZQejQ3qLstfZ2D3gVJxfMhJCpOKc3zPmTXvFhu5Ah3V+w7Fl1wO0rYAaAxt8PmoWHnsn9pfOxVAHoU9EbgcwvCaAVFFH X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0201MB1781; X-Microsoft-Exchange-Diagnostics: 1;BY2PR0201MB1781;25:KN43B1RyoJNuSIDxepEIUaYBNp+LBaEZNeXDOdQ7TyX6SJWNkBYxlVOeWTnYkIWB+EzQkMXTZghra5uYhih/t7hJT8MIbOS3IoLJjEvxIWz2rnAGTVtvfWWk6MKAd4IO6/FwRbuCE4HvC+CQoesyvLSUX8J221iksjI0NrxMXozcO6NuZoaZWqS9PCa0Ayhz7ghtD4iddiMMFWsNVS5QPhG73EMAMzmXQTt0BQZ0dOyOt0nwP+FV3XO+ms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wELwGUdau4PB3AN+jKJ9u7SjUxHZP0hV3YICnngRNoZlx+7+LlAnrz0Y9HtS+mwY0hKZD7T24nTG9dRxOld+xqFadrAdO1ji47BzFdFhD2I2k8EIfVLl2glDCwuCZosOEBrX/HKCBXv9bjZ8I4bFVFbysP+nmyvtbGqiZEoK5upSXxSNOhH0nex/JBS1SmWrT5ekb7+4yUQcFF/1HQJqXrO3yEogpC/GbuXGssZyjh0mzZWsUenQps2gSGH4cigLG0LzMHkYF/SjclRO2QjhiMbjBDUBitLxzCSigoXlu7KZsDTraU66U/+07CWQ== 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)(3002001)(10201501046);SRVR:BY2PR0201MB1781;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0201MB1781; X-Forefront-PRVS: 0923977CCA X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(377454003)(51444003)(24454002)(36756003)(66066001)(47776003)(64126003)(65956001)(65806001)(59896002)(92566002)(5004730100002)(83506001)(230700001)(19580395003)(19580405001)(1096002)(3846002)(586003)(6116002)(5008740100001)(561944003)(33656002)(2950100001)(77096005)(23746002)(2906002)(81166005)(86362001)(50466002)(107886002)(5001770100001)(189998001)(4001350100001)(50986999)(76176999)(54356999)(87266999)(65816999)(42186005);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR0201MB1781;H:tpl2.home;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;BY2PR0201MB1781;23:lpM2LOnXkK32zXjn8reTJAwW2D26ZnqPSPw?= =?Windows-1252?Q?2orgdRqcWIT3CI5pD6a3p2swBHPSdC+IQ1riVitcKzOAdo0FF6b546tW?= =?Windows-1252?Q?fjAbErIQL0O+7uHvUuqofG1rzT6ix1qO/jT9fSiJEdDY6yuGeUNBt7Al?= =?Windows-1252?Q?JoOMRE5Jo3mYt0SkxHtJb7t83q+2CJgKDEb78MuhDTAoyiN63hpxibyn?= =?Windows-1252?Q?qWNKswxS1NFClwKF9B1CIuaoj6YnGGSQJlGKJSeUyoHjW/9NyWs2bzLJ?= =?Windows-1252?Q?ig8phVypP5bB3PwVDgrrovgtCZSXteNXlFkoGQ7BR9dpDli5A6ldpby7?= =?Windows-1252?Q?YPqAp2woXCN+4yu+AiKQBzbV0HO66WbfFFeBKEPCCSRne6pJMGnun6cu?= =?Windows-1252?Q?Hje2/r3UgI50NJHakiJqUR0KJmAg5Uo12U1D3P+EAscvlAcu1dc9ONoX?= =?Windows-1252?Q?/WMIgHA8CA4LZziOLk4mpcB5PVMtewCleNyvK1NrPHBfA0pHKY03+uuw?= =?Windows-1252?Q?b4shlRuf36RKdgawCeOzUQayH1dDAoi7f0rSKZ1HZYRTQ6SDNy0jOFOd?= =?Windows-1252?Q?zFUN/QiI3Om9WRDeFYdrRiKWTIyC1bfNMUlzcQR9z3dqMbkkpDrs+xAJ?= =?Windows-1252?Q?PBIDX+f6bxCsT1LCLZeFQ13ZPXMARmIXBgxL1NeDXW971Msz6t0T+YY0?= =?Windows-1252?Q?woz0dbnAnwDruzpG29Bm0MnFU4a72Gq6RF8vMit7lPosfkOEAocpsRi6?= =?Windows-1252?Q?x0B3SHMZY5qtCh7HAssmV+ULvKgc5sUEMkKoaniNR6DobGZVNkuQ/bMr?= =?Windows-1252?Q?OOmMOkVfBajtzJ40DE8fBiD6nOTIS/WynzqGCIIvkMRzyui2WMx9v6mI?= =?Windows-1252?Q?LkxncCRFh+CPMHKtkXCao/HNUAtpGOID19JgVaTP88ewVJth9R9jN9aV?= =?Windows-1252?Q?D+1aPEWtsTjNnvHJSDu1aGqaI3gG3H66VU1IZBhC5PWuO6W5YZImtwMp?= =?Windows-1252?Q?dlgRlf/8Woyvb0ykzvoBXQpgmH8qn88rVxJVe+HeJLACO3St7dZDTCsw?= =?Windows-1252?Q?VI8Bok1y7RzcjcdhFDurR428H0u1KV52gCHRbMb8PHRL61+PQkFIHMlV?= =?Windows-1252?Q?cvHhDi2I7LLz0KyDM3mV4ykIet0uE50Lb0UdR0Gd16SQ9aMIb7ic1pYg?= =?Windows-1252?Q?iNsnCHvbmdKZlycYW0aQwQfKXwNZqHWw=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR0201MB1781;5:PPa5aBvyqh72/L57Cd8i7sxFWB9hrykEx1XUipUt/St7oah5l20Tm1YKQk/B4fMZ7VCK3bnPdOjDFsM1WlfxaUUsl5X71daqqG0aE945GaigywqSDU3hco4xCYQn+Ogdkyg3OZm/Af4T8x1Ltg1hBzA8HhtsoZv5tUNOkfq/bJPfTQyS9qmH9bzVxvMnu+AQ;24:9iMTzL8L+DVdatNABTxJ4jb4anbEzSqRCg4x8LY6P/taZY/W0ZK2P9Y2uJp6IcIfJ/LpQ4Tl9VQFzWDkOSCP9FhwYql1B5HeHxUUaLZW4Yw=;7:zimMWREWrKVZ2GLQO1+XNOxEA+h5eTStwqU5IdLKJUZeejw/TTlFMxBgkZc+QzdRRNa0kUPWuPUPYYcPK6tleBnDfxSf2KA86mkMAB9lKTHRkcdZ2ioGri/xtNR9RoFEBNzcJqIUNW0UT0IijVodajDoNbYiRmtbTaP05bc9gBAHrmkwALtqIsrmW1k+5S7FgKGmF9rGZu+OF6zFtuceITSCgmk/x/ix7hNnxEqrWEY= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2016 09:07:10.3046 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0201MB1781 Subject: Re: [PHP-DEV] [RFC] PHP Attributes From: dmitry@zend.com (Dmitry Stogov) On 04/24/2016 02:09 AM, Thomas Bley wrote: > The <<>> syntax comes with the problem that previous versions cannot ignore it on parsing. > So poeple write new frameworks for 7.0 which cannot be parsed in 5.x, then they write new frameworks for 7.1 which cannot be parsed with 7.0 and 5.x and so on. > For companies staying on Linux distributions with long term support on 7.0, this is rather a nightmare for both users and framework maintainers. > When choosing <<>> or any other non-backward compatible syntax for 7.1, there should be a patch for 7.0 to ignore the new syntax without parse errors. Good point, but any syntax proposed for native attributes would break forward-compatibility as well. The only choice to stay with doc-comments and do all the work at user level. Thanks. Dmitry. > > Regards > Thomas > > Fleshgrinder wrote on 23.04.2016 17:29: > >> +1 for the basic idea, however, I have various remarks. >> >> The RFC text is hard to read and contains many grammatical mistakes. How >> could one help you here? >> >> I think that the Hack name attributes is unintelligible and annotations >> would be much clearer to any audience. Simply because the name is very >> well known. >> >> I do not see the need for multi-annotation nor multi-value support. It >> just creates multiple ways to achieve the exact same thing for no good >> reason. >> >> I do not like the <<>> syntax. It requires many key strokes, is hard to >> read, and looks ugly. Why not simply @ and be done with it. I am not so >> sure about the bracket requirement, is it somehow required for the >> parsing? Otherwise I would leave it off. I guess it might be hard to >> find the end of an annotation but have you considered to use the >> semicolon for that? Would align nicely with existing PHP syntax. The >> following would be the ABNF for my proposal: >> >> ANNOTATION = "@" NAME [ " " VALUE ] >> NAME = STRING >> VALUE = QUOTED-STRING / PHP-CONSTANT / EXPRESSION >> QUOTED-STRING = ( "'" / DQUOTE ) STRING ( "'" / DQUOTE ) >> EXPRESSION = PHP-CODE ";" >> >> A semicolon would only be required if it is not a single quoted string >> (see following example) or constant. A question that I see unanswered is >> how embedding of variables in quoted strings should be dealt with. I see >> no need for this but people might assume it is supported because PHP >> supports it everywhere else. >> >> > >> $name = "Richard Fussenegger"; >> $email = "php@fleshgrinder.com"; >> >> @author "{$name} <{$email}>" >> class A {} >> >> <")>> >> class B {} >> >> ?> >> >> Requiring PHP code to be terminated with a semicolon should also ensure >> that people do not start to write fully-fledged programs in annotations. >> Since that is not what they are intended for. An alternative approach I >> see here would be to go for the brackets but then again only for PHP code: >> >> EXPRESSION = "(" PHP-CODE ")" >> >> Then again, it looks similar to a function call and this is imho not >> good. Unless of course new annotations can be defined as special >> functions directly in userland, e.g. with an `annotation function` >> and/or `annotation class`. However, this would require more thought. >> >> Another question that is unanswered for me is: how to go about adding >> annotations to a complete file as is currently possible with PhpDoc and >> its file-level doc block: >> >> > @author 'Richard Fussenegger ' >> @copyright '2016 Richard Fussenegger' >> @license 'MIT' >> >> declare(strict_types=1); >> >> namespace Fleshgrinder\PhpInternals; >> >> @description 'True annotation support could be a very good thing.' >> @invariant $this->balance >= self::MIN_BALANCE; >> class Account { >> >> private const int MIN_BALANCE = 0; >> >> private int $balance; >> >> private Person $owner; >> >> @require $sum >= 0; >> @ensure $this->balance === (old::$balance + $sum); >> public function deposit(int $sum): void { >> $this->balance += $sum; >> } >> >> @require $sum >= 0; >> @require $sum <= $this->balance - self::MIN_BALANCE; >> @ensure $this->balance === (old::$balance - $sum); >> public function withdraw(int $sum): void { >> $this->balance -= $sum; >> } >> >> @deprecated 'for various reasons' >> public function setOwner(Person $wner): void { >> $this->owner = $owner; >> } >> >> } >> >> @inheritDoc >> class OverdraftAccount extends Account { >> >> private const int MIN_BALANCE = -1000; >> >> } >> >> ?> >> >> We also need to make sure to add something regarding coding standards >> for annotation names. I would propose to go for camelCase (same as for >> method names) since this is what PhpDoc used to use for many years now. >> >> We also need to define how people can avoid to collide with internal >> annotations. The typical double-underscore prefix approach that we have >> for magic methods creates a lot of visual clutter and looks weird if >> spread among all kinds of places. A namespace approach as we have it >> already for userland code could help here. >> >> > >> use Doctrine\ORM; >> >> @ORM::entity >> @ORM::table [ >> 'name' => 'user', >> 'unique_constraints' => [ >> 'name' => 'user_unique', >> 'columns' => [ 'username' ], >> ], >> 'indexes' => [ >> 'name' => 'user_idx', >> 'clumns' => [ 'email' ], >> ], >> 'schema' => 'schema_name', >> ]; >> class User {} >> >> ?> >> >> -- >> Richard "Fleshgrinder" Fussenegger >> >>