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

Closed
doctrinebot opened this Issue Feb 13, 2012 · 4 comments

2 participants

@doctrinebot

Jira issue originally created by user totolehero:

When i use the keyword 'use' in anonymous function (like describe in page http://php.net/manual/en/functions.anonymous.php)

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

[ErrorException]

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

@doctrinebot

Comment created by @FabioBatSilva:

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

@doctrinebot

Comment created by @FabioBatSilva:

Coverage added : 7ec510d

I think this could be closed..

@doctrinebot

Comment created by @FabioBatSilva:

Fixed on php parser rewrite. (2.2)

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label Dec 7, 2015
@beberlei beberlei was assigned by doctrinebot Dec 7, 2015
@doctrinebot doctrinebot added this to the 2.2 milestone Dec 7, 2015
@doctrinebot doctrinebot closed this Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment