Annotations in Doctrine Common are meant to fill a gap of annotations missing in PHP. Their meaning is exactly what you'd meet in Java or C#. They are a workaround since the annotations RFC didn't make it to PHP core. Consider them as if they were _EXACTLY_ Java annotations.
Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 22 October 2012 22:25, Nikita Nefedov <[email protected]> wrote: > Yep, I understand. But as long as php don't have annotations like in Java, > our "annotations" is just comments. > Don't get me wrong, I'm not against annotations, but this just looks ugly. > Either way, they are handy, because they are right near to code they > related to, but we don't have annotation mechanism like Java have and we > shouldn't use it like Java forces Java-ers to use it just because it's not > Java (or C#). > > On Monday, October 22, 2012 11:01:15 PM UTC+4, Marco Pivetta wrote: > >> 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 > -- 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
