While PHPDoc is metadata that is useful and does not have effect on how
code behaves, annotations are a quite different concept coming from the
java world (where they're actually a construct recognized by the language).
Don't confuse them, they should not be mixed up. One provides some sort of
functionality, the other is just descriptive.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/



On 22 October 2012 09:15, Nikita Nefedov <[email protected]> wrote:

> Hi,
>
> I just though, why we are using so complicated style for declaring
> dependencies in annotations?
> Look: if I want to create some service, that are depends on request,
> entity_manager, etc. I need to write that (sorry, don't know how to format
> code here):
>
> use JMS\DiExtraBundle\Annotation\Service,
>       JMS\DiExtraBundle\Annotation\Inject,
>       JMS\DiExtraBundle\Annotation\InjectParams;
>
> /**
>  * @Service
>  */
> class Service
> {
>
>     /**
>      * @InjectParams({
>      *   "request" = @Inject("request"),
>      *   "em"       = @Inject("doctrine.orm.entity_manager"),
>      *   ...
>      * })
>      */
>     public function __construct($request, $em, ...) {}
> ....
> }
>
> But can't we just use default @param annotation for that purposes?
> For our example it would be:
>
> use JMS\DiExtraBundle\Annotation\Service,
>       Symfony\Component\HttpFoundation\Request,
>       Doctrine\ORM\EntityManager;
>
> /**
>  * @Service
>  */
> class Service
> {
>
>     /**
>      * @param Request $request "request"
>      * @param EntityManager $em "doctrine.orm.entity_manager"
>      */
>     public function __construct($request, $em, ...) {}
> ....
> }
>
>
> The thing is: we are already at that point, where all this annotations
> became ridiculously big (I mean, they are taking more space than code
> itself) and from other side - we always write phpdocs, just for documenting
> our code. So, why not use phpdocs, that are already can give us a lot of
> information, instead of creating a lot of classes for annotations?
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/symfony-devs?hl=en
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to