Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49523 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16668 invoked from network); 25 Aug 2010 18:22:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Aug 2010 18:22:20 -0000 Authentication-Results: pb1.pair.com header.from=christian.kaps@mohiva.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=christian.kaps@mohiva.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain mohiva.com designates 78.46.69.5 as permitted sender) X-PHP-List-Original-Sender: christian.kaps@mohiva.com X-Host-Fingerprint: 78.46.69.5 zucker.schokokeks.org Received: from [78.46.69.5] ([78.46.69.5:50683] helo=zucker.schokokeks.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1D/72-02448-B5F557C4 for ; Wed, 25 Aug 2010 14:22:20 -0400 Received: from [192.168.178.2] (p57B533D0.dip.t-dialin.net [::ffff:87.181.51.208]) (AUTH: PLAIN christian.kaps@mohiva.com, SSL: TLSv1/SSLv3,256bits,CAMELLIA256-SHA) by zucker.schokokeks.org with esmtp; Wed, 25 Aug 2010 20:22:15 +0200 id 0000000000018006.000000004C755F58.00006A5A Message-ID: <4C755F57.10807@mohiva.com> Date: Wed, 25 Aug 2010 20:22:15 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100807 Lightning/1.0b2pre Thunderbird/3.1.2 MIME-Version: 1.0 To: Pierrick Charron , internals@lists.php.net References: <20100825132918.GA27628@mig9.immomigsa.ch> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Annotation RFC + Patch From: christian.kaps@mohiva.com (Christian Kaps) Hi, I love this RFC. But I have a view questions. 1. > Since php does not support named parameter the __construct is called > with an array as parameter > [Foo("bar", baz="baz)] > will call __construct(array("value" => "bar", "baz" => "baz)); > I am a absolute C noob but I have implemented named and unnamed exceptions in userland. So it should also be possible in C, or not!? Are the names from the constructor parameters not available through the reflection API? This may be a little bit more overhead but I think unnamed annotations are very useful. [URL('http://www.php.net', 'PHP', 'blank')] or [URL('http://www.php.net', 'PHP')] or [URL('url' = 'http://www.php.net', 'name' = 'PHP', 'target' = 'blank')] class URL extends ReflectionAnnotation { public function __construct($url, $name, $target = 'self') { } } instead of [URL('url' = 'http://www.php.net', 'name' = 'PHP', 'target' = 'blank')] class URL extends ReflectionAnnotation { public $url; public $title; public $target = 'self'; public function __construct($params) { } } For me an additional point for providing unnamed annotations is the possibility to use type hinting. So it isn't possible to pass an integer when an array is expected. I know I can validate the parameters in the constructor. But this is additional work. 2. Is it possible to use nested annotations and what is the syntax? 3. > AliasedName is not implemented yet, but I added in RFC as one of the > first enhancements to be done. > The purpose of it is to reduce the over-typing needed to instantiate > namespaced classes. > > Here is the first idea: > > ReflectionAnnotation::addNamespaceAlias('Doctrine', 'Doctrine\ORM\Mapping'); > > [Doctrine:Entity] > > would be the same to > > [\Doctrine\ORM\Mapping\Entity] Is it possible to define a use statement for an annotation instead of defining the namespace alias over the reflection API? namespace com\mohiva\framework\cache; use com\mohiva\framework\annotations\File; [File('/path/to/the/file')] Greetings, Christian