Skip to content


DCOM-97: phpParser.php and 'use' keyword in anonymous functions #698

doctrinebot opened this Issue · 4 comments

2 participants


Jira issue originally created by user totolehero:

When i use the keyword 'use' in anonymous function (like describe in page

Exemple :

* Extract event from all events for this day
* @param int $year
* @param int $month
* @param int $day
* @return ArrayCollection
public function getEventsForDate($year, $month, $day)
$extractEvents = null;
// check if date of item is inside day given
$extractEvents = $this->events->filter(
function ($item) use ($year, $month, $day)
$leftDate = new \DateTime($year.'-'.$month.'-'.$day.' 00:00');
$rigthDate = new \DateTime($year.'-'.$month.'-'.$day.' +1 day 00:00');

                return ( ( $leftDate <= $item->getDateStart() ) && ( $item->getDateStart() < $rigthDate ) );
    return $extractEvents;



The phpParser generate error


Notice: Undefined offset: -1 in /home/ent/project/Symfony/vendor/doctrine-common/lib/Doctrine/Common/Annotations/PhpParser.php line 117

It try to parse 'use ($year, $month, $day)' as Class


Comment created by @FabioBatSilva:

I think this is fixed on the php parser rewrite. (2.2)


Comment created by @FabioBatSilva:

Coverage added : 7ec510d

I think this could be closed..


Comment created by @FabioBatSilva:

Fixed on php parser rewrite. (2.2)


Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label
@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.2 milestone
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.