Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92677 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84445 invoked from network); 24 Apr 2016 08:24:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Apr 2016 08:24:25 -0000 Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 77.244.243.87 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.87 mx106.easyname.com Received: from [77.244.243.87] ([77.244.243.87:51460] helo=mx201.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 12/C0-14846-8B28C175 for ; Sun, 24 Apr 2016 04:24:24 -0400 Received: from cable-81-173-133-226.netcologne.de ([81.173.133.226] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1auFL2-0004HR-HA; Sun, 24 Apr 2016 08:24:20 +0000 Reply-To: internals@lists.php.net References: <571BA0F0.2030400@fleshgrinder.com> To: Sara Golemon , internals , "dmitry@zend.com >> Dmitry Stogov" Message-ID: <571C82A7.2060706@fleshgrinder.com> Date: Sun, 24 Apr 2016 10:24:07 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <571BA0F0.2030400@fleshgrinder.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Bsn8bCbmqKx03QtVHCkBNaljqk4RqxhbX" X-ACL-Warn: X-DNSBL-BARRACUDACENTRAL Subject: Re: [PHP-DEV] [RFC] PHP Attributes From: php@fleshgrinder.com (Fleshgrinder) --Bsn8bCbmqKx03QtVHCkBNaljqk4RqxhbX Content-Type: multipart/mixed; boundary="vBkPScQjqEL6eINMXdt0FXF2mDlpu3fWQ" From: Fleshgrinder Reply-To: internals@lists.php.net To: Sara Golemon , internals , "dmitry@zend.com >> Dmitry Stogov" Message-ID: <571C82A7.2060706@fleshgrinder.com> Subject: Re: [PHP-DEV] [RFC] PHP Attributes References: <571BA0F0.2030400@fleshgrinder.com> In-Reply-To: <571BA0F0.2030400@fleshgrinder.com> --vBkPScQjqEL6eINMXdt0FXF2mDlpu3fWQ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable The invariant could also be added as an additional branch to the class instead of a method, since it would not work like a method. class A {} invariant {} function f() {} require {} ensure {} This would also align nicely with closures and anonymous classes, which is kind a problematic with annotations. $A =3D new class {} invariant {}; $f =3D function () {} require {} ensure {}; The only thing that remains that might be of interest to both is `@throws` but that was not discussed at all as of yet. use Ns\SomeException; @throws SomeException function f() { } This is at least how one would expect it to work and it is something that should be covered by annotations and not as part of the language. The ABNF should account for that: ANNOTATION =3D "@" NAME [ " " VALUE ] NAME =3D STRING VALUE =3D QUOTED-STRING / PHP-REFERENCE / EXPRESSION QUOTED-STRING =3D ( "'" / DQUOTE ) STRING ( "'" / DQUOTE ) EXPRESSION =3D PHP-CODE ";" Where PHP references are any of the already possible ones: use F\Q\C\N; @annotation \F\Q\C\N @annotation N @annotation \F\Q\C\N::CONSTANT @annotation N::CONSTANT @annotation \F\Q\C\N::function() @annotation N::function() @annotation \F\Q\C\N::$variable @annotation N::$variable I also though some more about function support for annotations and this would actually be a nice thing for userland. annotation deprecated(Reflection $element, string $message =3D '') { @trigger_error($message, E_USER_DEPRECATED); } @deprecated('because') function x() {} @deprecated function y() {} This would allow users to implement simple and easy reactive annotations in userland. Even if this could or should be an extension of the feature in the future, it should be thought about know. Simply because the brackets make sense if such a feature is to be implemented. ;) --=20 Richard "Fleshgrinder" Fussenegger --vBkPScQjqEL6eINMXdt0FXF2mDlpu3fWQ-- --Bsn8bCbmqKx03QtVHCkBNaljqk4RqxhbX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXHIKrAAoJEOKkKcqFPVVrHyAQAMmw0NFJVie9ON09kViyiQJY aG98s8S1/i4q8bDW2pkJMH3OFxrNFdBN1ptGnrsGOhr42AclRn+K5y39WTqWNhsV 3OOGu2b/6urEdlpyAZ8hegs8xmOUjtzYT4L3SLM8AFCCBB0hszJRulHPtCAxENEq dh7/R7xmqafoz2gWNyvSL6UZ661uhbnYu3bMsHwmEbAmd638fHlA5BuQC0RbaIaX Qfzsh0KPdhwagoPoNBvsEH0mMYonS2S6wK/+/phU5hRBk2YSAfnkIpR/0Pat7iZ1 hSAyR5v7kLGlj+rXUJdxslyvtRQ/6Km4YFIQUyE2ZNdqWyPcd+jEKwwnk/AXo4kI +yP1nft+Df9CR70apMBGpRqzil3vaFWhpXXLz9NgZNwsoCz92rOBEHugNjFlgpQn XOkb7j+01PTh+zNaXvVk64rX+czejM4hZJL9euVOxtoxskIK5T47y8kB0qKh/avZ yJPVL7zmkHnoMzNrapNGs8TojwUllaATYbrfBgC2q0tZp8LCn+hdqZ7HCjPdbZr3 4pmwgRmJ1I2/AP83I/LYtStlK5zPJDHRGMYZTgDCLpDO6VfJK/UUS46Zrz7kWHs3 pecxny+X6jAf+/kadvJRCUgarcpR4bkK1+dOmAuKyyXyek0E95Q9zFq/RH3HGPjh uSSC79TlishgjFbKEyOg =3OKC -----END PGP SIGNATURE----- --Bsn8bCbmqKx03QtVHCkBNaljqk4RqxhbX--