Hi Stas and Christian,

The separator never was a problem... but I definately don't want to
see another 6 months just to define what would the separator be.
If we need to drop [] in favor of array support, I vote for ! as separator.

!Author("Guilherme Blanco")
!Validation(!Email(checkMX = true))


@Stas: Explaining the example of class User {
[Validation([Email(checkMX = true)])] public $email; }

class Validation extends \ReflectionAnnotation {}
class Email extends \ReflectionAnnotation {
    protected $checkMX;

    public function getCheckMX() { return $this->checkMX; }
}


$reflClass = new \ReflectionClass('User');
$reflProp = $reflClass->getProperty('email');

$emailAnnot = $reflProp->getAnnotation('Validation')->getValue();
echo $emailAnnot->getCheckMX(); // true


I hope this helps to explain a little bit.


Cheers,

On Sat, Sep 11, 2010 at 8:00 AM, Christian Kaps
<christian.k...@mohiva.com> wrote:
>  Hi,
>
>>> %Annotation(%Email(checkMX = true));
>
> at first I thought what for an ugly syntax. But after a time I think it
> is regardless of whether the % or @(from Java, which I prefer over all,
> if it were possible) syntax is used. It looks very similar. So I prefer
> the % syntax so we can use the [] for defining arrays in annotations. Is
> it possible to define objects from type stdClass in the form
> %Annotation({key: 'value'})?
>
> An other question. Is it necessary to terminate an annotation with a
> semicolon, like in your example?
>
> class Compiler {
>
>    /**
>     * Compile a node into plain PHP.
>     *
>     * @param Node $node The node to compile.
>     */
>    %Annotation(%Email(checkMX = true))
>    %ResourceParameter(['key' => 'name', 'value' => 'annotation'])
>    %Inject('\my\name\space\Class')
>    %Test
>    %Annotation({key: 'value'})
>    public function compile(Node $node) {
>
>    }
> }
>
> Greetings,
> Christian
>
> Am 11.09.2010 02:23, schrieb Pierrick Charron:
>> Hi Stas,
>>
>> Annotations is a new concept in PHP (even if some framework already
>> use an user space implementation of them) and I think it is normal
>> that people will have to read a little bit about this eventually new
>> feature before using it. This is the same thing for traits, if you
>> don't know what is a trait you will not know how to use them. But once
>> you know the concept it's really easy to understand what is an
>> annotation class, parameter etc...
>>
>> Is it really the [] Syntax that you don't like for annotations ? I was
>> personally not against the [] array syntax and I understand that this
>> annotation syntax will make the future implementation of this [] array
>> syntax impossible. So I could change it to the syntax proposed by
>> Etienne in the first thread :
>>
>> %Annotation(%Email(checkMX = true));
>>
>> I'm not against any other proposal of syntax so if you have one to
>> proposition do not hesitate.
>>
>> Regards,
>> Pierrick
>>
>>
>>
>> 2010/9/10 Stas Malyshev <smalys...@sugarcrm.com>:
>>> Hi!
>>>
>>>> [Validation(Email(checkMX=>true))] looks better.
>>> Even here it's not clear what is happening. What is "Validation", what is
>>> "Email", what is "checkMX" (are they all classes? or only some of them?),
>>> what is happening to them (are these classes being instantiated? when? what
>>> is passed as parameters? What is the scope of that? etc). Why can we have
>>> now two ways to instantiate classes, complete with mix of []s and ()s, but
>>> having array syntax using [] is still too complex?
>>>
>>> --
>>> Stanislav Malyshev, Software Architect
>>> SugarCRM: http://www.sugarcrm.com/
>>> (408)454-6900 ext. 227
>>>
>>> --
>>> PHP Internals - PHP Runtime Development Mailing List
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Guilherme Blanco
Mobile: +55 (16) 9215-8480
MSN: guilhermebla...@hotmail.com
São Paulo - SP/Brazil

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to