Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92713 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2040 invoked from network); 25 Apr 2016 08:31:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Apr 2016 08:31:45 -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.145 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 65.55.169.145 mail-bl2on0145.outbound.protection.outlook.com Received: from [65.55.169.145] ([65.55.169.145:20112] helo=na01-bl2-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8A/50-00233-0F5DD175 for ; Mon, 25 Apr 2016 04:31:45 -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=UquW5Y/7E8523p8qfHzIVGrhcpMVh3BUzEa4hKARGk4=; b=PyoqSXmf/KOLeJH+h6JWJWfsPDCDjTQYq20aiVkVnMqQ7pQMB5IC+kdDiEWEceuh2CBlH7MvLjhT/o7zffNfXyyAnHRw1GsTzXtAan2n4wU8UPj7iy09JEFACt+1XWubQducOpI1tfbJK7E5/LBvxv2VrJ1IBzFVTchMmLb0hqk= 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 BY2PR0201MB1783.namprd02.prod.outlook.com (10.163.72.25) with Microsoft SMTP Server (TLS) id 15.1.466.19; Mon, 25 Apr 2016 08:31:40 +0000 To: References: <571B94C1.1070307@fleshgrinder.com> Message-ID: <571DD5DF.9090906@zend.com> Date: Mon, 25 Apr 2016 11:31:27 +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: <571B94C1.1070307@fleshgrinder.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [92.62.57.172] X-ClientProxiedBy: AM3PR07CA0017.eurprd07.prod.outlook.com (10.141.45.145) To BY2PR0201MB1783.namprd02.prod.outlook.com (10.163.72.25) X-MS-Office365-Filtering-Correlation-Id: 19710420-7948-439f-8abd-08d36ce406c3 X-Microsoft-Exchange-Diagnostics: 1;BY2PR0201MB1783;2:V+LEeFE6C1hDeQ80EblIx7CwYurI2jFcx01QIwGaIkstz8lNcKpM3lDOPLv8Vizv3/x5YIBa83JMQEa20tNh2eaToBBEH0I192jmpNegqpBRsw8/Z4jviRWPLCq+LEUAROiIuSJOQCKhiZcH4NJoQeXyR1orA3+UFFjgVV4oIe0xz8ooFBcFZWaHuObznGFn;3:xPNWbGpv3bzAbWYAJ4n/3mWHjmc8CIzwRQ65SkqvNNURBjZcl03MGiJrc1Pajoo32Q7o6CH6f37wqy/85PP54pCOcgsax8xMsSBbuEyFIsh8dn0XVdmLJqP8dNXSMGJ/;25:BBfQhxuMtiJRLWBlp1pV6C3bDeehYwCf+GS/m3P32OGlTX9WvLpj3xgo+5AnugQopgxDdl+3ptHAGsuVwdBOu0H9pNObcKS2djZiwNx3vLC5ax2H1lo9EudGNC0TcTeMeOXdfQ8/2/GE0h8J2ZUKjLGn+4niCP3NEjVU2Ae4rVVxVD0/ZcF6sjpIOeUcWuUbBtDuxG+lfEPPJsMZsGLNK9lyd5pQQ/EVWtJTngbQVeNLYHkYThxTyxjD1VmTGxw0hkPQtjBD8axbj9HPixyVz5CKwNAx6Kapvub9keu3MBXa+MbV489tVaTi/+mh9f2TeXqgXHWCS6yaKiGUeQypBQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0201MB1783; X-Microsoft-Exchange-Diagnostics: 1;BY2PR0201MB1783;20:oGAVstyJbHrdaA0Ot4+6LwBCilQBm4rt7d0zYzjhA4tw1id6hRd5oD+lwGMPW/4pYAtDNjqwmIkaZzmexLr/d4XisgFIlXjnOJuDYNdbCtuvE8mPksWz7icc410KbazVjeyAGp22DA/oyL+EzJHQPrgjMosqqdkb+VvfrupJb+CkIDhbjJyguLdcol1IxNa6Nl/VQ/FalR8/BrbSrFnJu5kOnLwI7w9tk9jWomKWEUau/bX43xeYiF+XrVcOrLmsTxoeBe3BM6fx6kW7T+woxa5ST6h189zlaPzBXnBZse1Iovs4i5/YOz96GT+75DNcgUCMIjtpReIxU+VJKA7Dc7xspVkoHDPwowfq5RVaTx5BiGBG7hF91Jyc00y0MVsuUUUlFTrm32RJY3ms0fAMwr+2oTyJOfYTrAMfgXk/Lw5Ri0M7cpVZBGFbxxeBmcotLd2OKFHaeJxVcD1tFyzeKBkF9opJ6xSJRcpnO9yTIbCjOdzK+xtGfKe0RLTPQQ7Y;4:pN5ikLqzJtiTXfk3oOgb7KXrriYOXXaPU2Y3kObiaMRc7ZyUegJqOjZvJLlLfUYcMwtGDRq0mX3lgHuCRQOZxhnS5d+4HXpUdGUczK+3D7GBsIl1dcnla/IQfUGgympLHhIAnLJacgFfM9Y9x3rYIFLCrYfrH0h9QtpWh4JQDK7TE8wzAWySul0M3MoxB0DoPkscd5DWob7drWeCiw57TJe6ThFivDzMk2jc7VEwpMSg+z20yQYKQT6/+44+R7S2k0u5c+k0eArgyEYjMzYeYTzz8pW7rqQUx1o9rxxhrgC8u+ZLUN1+m8GqrbxBd5fqY/f08MfWnZfslp5bq75sFmB+VWhDnZxSc1FJyfbkJTShSZemGUzGVGuPKljE1CDLVUqyOCV1n0NuJ+S7FP3PRQ== 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:BY2PR0201MB1783;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0201MB1783; X-Forefront-PRVS: 0923977CCA X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(377454003)(24454002)(51444003)(42186005)(189998001)(5004730100002)(36756003)(77096005)(450100001)(66066001)(65806001)(83506001)(65956001)(76176999)(54356999)(87266999)(50986999)(65816999)(86362001)(23746002)(47776003)(561944003)(33656002)(4001350100001)(107886002)(110136002)(59896002)(19580405001)(19580395003)(3846002)(6116002)(2906002)(81166005)(586003)(2351001)(2950100001)(50466002)(230700001)(5008740100001)(92566002)(1096002)(64126003);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR0201MB1783;H:tpl2.home;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;BY2PR0201MB1783;23:Dm0YiTEJFVrsRbXXM5K2mCwo3PZJDd5+p0o?= =?Windows-1252?Q?JIgoH0+QWs4A4OrH40KcJURIL2uAcsskLtSgSylWsK8ymaOf9MA3Fz81?= =?Windows-1252?Q?46Ssh+Gs7QX5RJew7uaPFXqwgCQRRAz/ecjph59HmX8lz6NDzAn03asB?= =?Windows-1252?Q?hDKw531qM70fguhzb5Hd0qHKWWjyM7OpB1yGVkA/I3fyXyBdJHXxv6iB?= =?Windows-1252?Q?6aMdMyp9dzFLAtMXGbQp9xoV30HJCeyJvYmZn6q1Yivj9Ao9B2gCs2an?= =?Windows-1252?Q?+Nkwcw/lVusDEXUpzUulerMQ3z70Nqk3mH6Osk+Si3pfS59ndXg7ohLG?= =?Windows-1252?Q?lxlSiAo+CBkJ/CkLCHRFmvf12x/ZNwxcTKgD/1auMIO9EUfGLaB50OHd?= =?Windows-1252?Q?4cxLeFnS3f43ovRSnjkf12S5/T729DxwTl5eZlD93gOTS7AOE0zS0+vO?= =?Windows-1252?Q?5LnV1kx2Av1f/roq3inlNgyIPm3LppDCi2dabQKauAH+MSZgHPXYkzkg?= =?Windows-1252?Q?zWfPB5qAjkgSLiAfdsmzVkZ03IpZt6Lyg9RzzVeqG5SMZY2B+JXiK5My?= =?Windows-1252?Q?rp9e0415+GE93c+05V9SkD4dvGYS+62QReN6XsuZ7SkCRM7WDDJQyxTO?= =?Windows-1252?Q?MQbob48V1S/1V7GfGx944MSQ4nwYraksrW0xxvgvFzYZ9pDczNe2rSed?= =?Windows-1252?Q?7YjuUCSD/bvPFin11+QG6VkDPJprefmKjhDJGBkzU0G2XPgqBPZXHkDw?= =?Windows-1252?Q?Czzo86UOk4R1Hxy2KpAlgkGn4FkbE2DBbamsRHEE7COyPMXKntOm0QqI?= =?Windows-1252?Q?qg0mRwSEu6Hm8fhWV5EjiKwenieD0LnpPLHKFUxhWPhak/fCAfQz2AMU?= =?Windows-1252?Q?ZoKVVhPPniErAaVMGFB8fRJ0pk2b+V8d+Wo86eSLqpGbv4CDZ4J1sUBe?= =?Windows-1252?Q?52e1d+vdk1QjVuloc6WE3gDpkSVQAogHXBpjJb06RvVMyxxNoyIqQ7Wf?= =?Windows-1252?Q?FsHyXqgVGe0D20nH7cghIORRrvhUPOMCUHhG6XYxgA30Zqc1V9wBsfG1?= =?Windows-1252?Q?TrB4RsWrAL/waKEYM7t0iITdVa1nTx5EJjThO+OXKEEcNRCHIZor7PG9?= =?Windows-1252?Q?3BMqCH74ClNExGsjWIXuhq7JdlOECZqMKmX9b7xRCTXIkTJPbUrlmS1U?= =?Windows-1252?Q?dTFz8Hjbdue9Q/Zt40u4W0EAE831H/RLgtl4IGGkT0ibB7MGAzAYJclS?= =?Windows-1252?Q?udsnsT7IXNUE6cN/GgA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR0201MB1783;5:+FtMoZZ8zeJpbR4uAWOf/zDDf2Sz538ZpOgUQGI+HEvbd4222QIa9Gi8BiTA92M+Z0bPKZ47TqhPlTukU8N2mDxMAK96XIvoR6sJbRZzAtD8cNucVxOSJXcHyXHSVfmhfvB5owNwlKralo+u/MTC8Q30lC1OIy/xSv/xqS/5W2PMqP7OMlOTexZ3/+0RV/FC;24:k2timwRTKdf+LUpLNubo23nOm/tA6JQ82wECxoYrVG/9N7MbkIMd4j45+Wsbvevt3sS8b6tTS1dENOIfZtbFaSyGRqrwcFc9RqoStr20MH4=;7:kNfDNavxaQSnJntQMo7htw/H6aoM9Jjx0F/chn5ldXrm92txJFd8iQr3AXSE0yb5bngaD4oXnEGnmQBdHJ9UCdt6KqDiU0skIJWZpyuNRWSd9sTqfgXwqLNGuJ7mJwlJaE3/jtMP1FXkErMWBdAwzz7xJhJuHbhDveohBdNrQa0mfiDf6jE85AKlZ11kpKK9s+dpdmKbJJuenjNSDc4OhWOueCZupuVqAMPsg7FimIY= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2016 08:31:40.5099 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0201MB1783 Subject: Re: [PHP-DEV] [RFC] PHP Attributes From: dmitry@zend.com (Dmitry Stogov) On 04/23/2016 06:29 PM, Fleshgrinder wrote: > +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 would need a co-author :) > > 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. Different languages names this differently. I may add an additional voting question - "annotation vs attributes?". > > 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. completely disagree. Each value in multi-value attribute may have its own meaning. e.g. <> > > 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; > > } > > ?> You should try to implement this syntax to understand the problem. It leads to parse conflicts. > 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. This RFC is not going to propose coding standards. > > 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 {} > > ?> > Agree. Namespaces looks better than "__" prefixes. Thanks. Dmitry.