Autocompletion with /** @var */ in closures
Hello everybody,
I don't know if it's a bug (if so I'll gladly make a real bug report) or just me, but I can't get autocompletion in a closure on the following kind of code :
It's written in a Symfony2 controller and use the Symfony2 DIC.
<?php
/** @var \MyBundle\Model\Checkout\Manager $manager */
$manager = $this->container->get('my_bundle.checkout_manager');
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher */
$eventDispatcher = $this->container->get('event_dispatcher');
// Create an event listener for the cart update
$eventDispatcher->addListener('cart.update', function() use ($manager) {
$manager->onCartUpdate(); // no autocompletion here on $manager and the method ->onCartUpdate is not recognized.
});
?>
But if I duplicate the /** @var */ comment inside the closure, then it works. Example:
<?php
/** @var \MyBundle\Model\Checkout\Manager $manager */
$manager = $this->container->get('my_bundle.checkout_manager');
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher */
$eventDispatcher = $this->container->get('event_dispatcher');
// Create an event listener for the cart update
$eventDispatcher->addListener('cart.update', function() use ($manager) {
/** @var \MyBundle\Model\Checkout\Manager $manager */
$manager->onCartUpdate(); // works fine !
});
?>
Do you guys have any clue why?
Thanks for your support.
请先登录再写评论。
Is there anybody here ?
I'm kinda feelin' alone...
Hi Dorian,
IMHO -- If you want guaranteed response and you are licensed user, then I think it will be better to contact support directly: support@jetbrains.com -- they are fast at responding.
Apparently all PHP-related devs are busy with upcoming v5, and only them (IMO of course) can tell you for sure if it is a bug or if it is supposed to be like that (missing feature/not implemented yet). If you feel that it is a bug (e.g. worked in previous versions), then feel free to submit new ticket on Issue Tracker (but please check for possible existing tickets first).
Thanks for your answer. I'll write them an email then. ;)