Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51673 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8942 invoked from network); 13 Mar 2011 20:50:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Mar 2011 20:50:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=marcelog@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=marcelog@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: marcelog@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:56718] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 14/E0-03696-C1E2D7D4 for ; Sun, 13 Mar 2011 15:50:37 -0500 Received: by qwi4 with SMTP id 4so861291qwi.29 for ; Sun, 13 Mar 2011 13:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=43UbIOsObB/GD6Ixsppv0L2Q8CSVFbIFQdT9XwN9UE0=; b=ROlEReJCZUp4G9gfdSqeBiPHArK2SwPHICq2qAfLdnqJNzXMLf0KjApt+tAbz+VIiE sjuS/aGVPZy6MfKf6Hv37OdQ/yZIzCZFDh8w7bPn8jRwv8OkdqqB1ThDzDtK18nQUdvF Dt/XNicLBVTSX7vhEVJXE6gspLKq0xt4US3ww= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=We6voy/at6vg5UwDC7/JoGYZ/lHmCiqgo4I3Br9C2L9ZJTdWph1i0DWZANfvMNVgbD 8YD7A2/MReGOjqppYjClx2EUmF6gej/wCR+AqGLwbp8QTwY5ydLXSM0lMxxUGROxIXy3 GYdcuy+K35E36kHqdwRZMIoaL+IHdULj92oPc= MIME-Version: 1.0 Received: by 10.229.127.88 with SMTP id f24mr9490977qcs.186.1300049433039; Sun, 13 Mar 2011 13:50:33 -0700 (PDT) Received: by 10.229.228.13 with HTTP; Sun, 13 Mar 2011 13:50:33 -0700 (PDT) Date: Sun, 13 Mar 2011 17:50:33 -0300 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: native php annotations From: marcelog@gmail.com (Marcelo Gornstein) Hello All, I'm new to this list, so please excuse me if this subject was already discussed, or proposed. I've made an experimental patch to ZendEngine/PHP (5.3.5) to allow native annotations (without doc comments), using the token @@ (the @ was already taken). It allows 0 or more annotations (with 0 or more arguments each one) for classes, properties, methods, and arguments for methods, like: @@Annotation(key=3D"value1") class A { @@Annotation(key=3D"value1") private $property; @@Annotation(key=3D"value1") private function aMethod(@@Annotation(key=3D"value1") @@Annotation2 $a,= $b) { ... } } The patch can be found at: https://github.com/marcelog/AnoForPHP. The annotations and their optional arguments can be retrieved via the getAnnotations() method of ReflectionClass, ReflectionMethod, ReflectionParameter, and ReflectionProperty. I plan to extend this patch with some extended functionality, like having PHP instantiate a given class for the given annotation. By using convention instead of configuration, the name of the annotation is the name of the class, which should also extend some PHP base class, like "Annotation". I'm basically looking for comments on the patch and the functionality, since I'm new to the ZendEngine as well. Again, I'm sorry if this post should not go here or there is not interest in such a feature in the language itself. Also, if I missed something in the code of the patch, because it's more like a proof-of-concept than a final formal proposal. Regards! -- // I don't sleep. I coffee. "Make everything as simple as possible, but not simpler." -- Albert Einstei= n "The class object inherits from Chuck Norris." "Chuck Norris can divide by zero and can unit test an entire application with a single assert." "There=E2=80=99s a lot of work happening behind the scenes, courtesy of the Spring AOP framework" "Why do I have this nagging hunch that you have no idea what you're doing?" "Any society that would give up a little liberty to gain a little security will deserve neither and lose both" - Benjamin Franklin