Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93361 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39868 invoked from network); 16 May 2016 18:40:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 May 2016 18:40:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 212.232.25.162 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 212.232.25.162 mx206.easyname.com Received: from [212.232.25.162] ([212.232.25.162:37550] helo=mx206.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 89/80-35937-0041A375 for ; Mon, 16 May 2016 14:40:01 -0400 Received: from cable-81-173-133-15.netcologne.de ([81.173.133.15] 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 1b2NQj-0007cx-LC; Mon, 16 May 2016 18:39:49 +0000 Reply-To: internals@lists.php.net References: <61e6a083-91c2-799f-9757-02f56fe184e9@gmail.com> To: Rasmus Schultz Cc: PHP internals Message-ID: Date: Mon, 16 May 2016 20:39:49 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="g5Vg5N96et6RBuPeBEjoRk3xS6q9E5MTX" X-ACL-Warn: X-DNSBL-BARRACUDACENTRAL Subject: Re: [PHP-DEV] [RFC] Simple Annotations From: php@fleshgrinder.com (Fleshgrinder) --g5Vg5N96et6RBuPeBEjoRk3xS6q9E5MTX Content-Type: multipart/mixed; boundary="cIdeAnjHwKu4n61RVI5nSuXo6sMGcIuAj" From: Fleshgrinder Reply-To: internals@lists.php.net To: Rasmus Schultz Cc: PHP internals Message-ID: Subject: Re: [PHP-DEV] [RFC] Simple Annotations References: <61e6a083-91c2-799f-9757-02f56fe184e9@gmail.com> In-Reply-To: --cIdeAnjHwKu4n61RVI5nSuXo6sMGcIuAj Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 5/16/2016 3:05 PM, Rasmus Schultz wrote: > I'm sorry, but I think that the idea of meta-data that can't error > somehow, somewhere, at some point, is completely unrealistic. >=20 > And I'd much rather have a simple facility that enables those errors > to surface quickly. >=20 It should error and it should error exactly at the point when you want to use it and at no other point. Right now they will error anytime anyone wants to do anything with any annotation. I fully understand the urge to directly access objects and I actually support it and I want them to error out at the point where you try to instantiate them. However, not when I simply access annotations in introspection. According to your logic I have to load the whole dependency chain, even thought I just want to generate my documentation that might have some annotations in use. I also need to load all my dependencies even though I wanted to leave the security dependency out because I wanted to easily disable the security annotation system locally for development. I even have to load the whole dependency chain, even though I just want to introspect the single data structure at hand without invoking anything. Even worse if I am using a package that has Doctrine annotations but I use it without them: /fatal error/ Nice? No! Solutions? Make the /simple/ annotations /simple/. ;-) Only allow scalar data to be defined and allow userland to register themselves for specific annotations. I mentioned this before but somehow everyone wants something more fancy and I have no karma (even though requested but ignored) to write my own RFC. That being said, you have the ability to write an RFC so please just take it. :-) Some PHP code to illustrate what I was thinking of since I am better with code than with words. :-P https://gist.github.com/Fleshgrinder/d26cd4751827b8c10a0dc33da32b48c3 Reflection is the wrong tool for the job to build annotation systems. Reflection should not be used in production it should be used to introspect data structures and reason about them or other stuff during unit tests. However, reflection should provide the ability to read annotations, it just does not do anything with them by default and outputs stupid arrays. You will definitely understand what I mean it you follow the Gist= =2E I am sure there is room for improvement and that I overlooked something in my Gist. But I think it is a starting point, some additional notes: - I do not see any benefit in annotations for parameters. - I do not see any benefit in annotations for Generators. - I do not see any benefit for annotations in php-src. My proposal would include to ban annotations from php-src and make it a pure userland functionality. This has many advantages: - No name collisions. - Clear policy for the future. - php-src features are never optional. - php-src does not provide meta-data. Let me know what you think or if you have questions in regards to the Gist that are unclear. (Or maybe you found mistakes.) --=20 Richard "Fleshgrinder" Fussenegger --cIdeAnjHwKu4n61RVI5nSuXo6sMGcIuAj-- --g5Vg5N96et6RBuPeBEjoRk3xS6q9E5MTX 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 iQIcBAEBCAAGBQJXOhP5AAoJEOKkKcqFPVVrD9IP/RbEczkaHjd7XkFzl9iLNFWp hQg0X7sT/ONZIBMK+jnKkTQ0mg2XfwSAHB8/AX93QHjVJrecfAqHNyMdyIxKHYXM umAU3SxQFD4ZbjiXZ827XScx+ScPM2FOnLVunLsGUYiCpclS6qRcgnrzcyQxga7d szjC8hqvsawh3zn9rhCW6uQeiNyM1J2c/mKNkV/oxHRkmy7DwCQydYIsijEo0zjZ gb31l9NT0Lod/2p9DRiXVqj4Vim+2NiQJs8JcKzh7jGOQZujzSaUQRmkRE+GC0Se MO8gBbS7jEfqDyOp+JkG5lNaSr/CCKAY/knX94BMlPo6Lzf/8NeVUZlpyYHtG2al 8gXYJ5oVCypwXX4UDwonJyp3yac6kTWGuD/o9QiV9IKCOgtnazCFW0QQA6LmnRwZ 8C7O3PJrB6e7o56ibUPhvk5UFNTxZ6htqOvIi4LD4/CaIGWLxXO1w+z9kpwe9Wdw K3afqlVrMxvzFvE48AOoTAXYLIF2DAIHV5inRCWVTAXtERzk1ednIq+6tqc9ZQG0 AwePlyHj1dYGbvbGIuimGzNYzGa5vXyyU3XlCTcs/D60O3FCwVBO716yy823UXyI wCIC0aQlr1bzU62ZSieY4rg7HnHJBAqhYO1OinFOk3ukRAf7mCvjDjmUOBgdYtHk Sw/4QPTh3Q08kP9vfokl =BRvT -----END PGP SIGNATURE----- --g5Vg5N96et6RBuPeBEjoRk3xS6q9E5MTX--