doctrine/doctrine2 — pull request #1142 by TwoWholeWorms (2014-09-22 19:20:36+00:00)
Title: func_get_args() call order fix for HHVM bug

This PR fixes bugs in `Doctrine\ORM\QueryBuilder` where the values provided to method arguments to `::andWhere()`, `::orWhere()`, `::andHaving()`, and `::orHaving()` are overwritten by code within the methods in HHVM and PHP7.

After much fun and headscratching in both #doctrine and #hhvm on Freenode, we discovered that in the following code, `$where = $this->getDqlPart('where');` overwrites the values stored internally for the `$where` parameter of the function which is returned by `func_get_args()`:

public function orWhere($where)
{
$where = $this->getDqlPart('where');
$args = func_get_args();
}

This means that instead of `$args` being set as expected to an array containing the string or object provided to the function, it actually contains the object returned by `QueryBuilder::getDqlPart()`, which causes all the problems you'd expect it to.

This PR simply swaps the order of the calls so that the function arguments are retrieved via `func_get_args()` before the `$where` variable is modified, fixing the problem.