From 589d26fc5e57a4950d106f5776fdaf066ff2f4ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Bere=C5=88?= Date: Tue, 2 Sep 2014 08:39:29 +0200 Subject: [PATCH] Changed calling $from[0] to using reset($from) changed usage $from[0] according suggestion from @Ocramius to use array reset function --- lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php | 3 ++- lib/Doctrine/ORM/Tools/Pagination/CountWalker.php | 3 ++- .../ORM/Tools/Pagination/LimitSubqueryOutputWalker.php | 3 ++- lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php | 3 ++- lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php index a65c73328..e44be6c57 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php @@ -96,7 +96,8 @@ class CountOutputWalker extends SqlWalker throw new \RuntimeException("Cannot count query which selects two FROM components, cannot make distinction"); } - $rootAlias = $from[0]->rangeVariableDeclaration->aliasIdentificationVariable; + $fromRoot = reset($from); + $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable; $rootClass = $this->queryComponents[$rootAlias]['metadata']; $rootIdentifier = $rootClass->identifier; diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php index 0aa6aebfc..ff0c6b363 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php @@ -58,7 +58,8 @@ class CountWalker extends TreeWalkerAdapter throw new \RuntimeException("Cannot count query which selects two FROM components, cannot make distinction"); } - $rootAlias = $from[0]->rangeVariableDeclaration->aliasIdentificationVariable; + $fromRoot = reset($from); + $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable; $rootClass = $queryComponents[$rootAlias]['metadata']; $identifierFieldName = $rootClass->getSingleIdentifierFieldName(); diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index 1b32fc97c..45a6ce78b 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -122,7 +122,8 @@ class LimitSubqueryOutputWalker extends SqlWalker throw new \RuntimeException("Cannot count query which selects two FROM components, cannot make distinction"); } - $rootAlias = $from[0]->rangeVariableDeclaration->aliasIdentificationVariable; + $fromRoot = reset($from); + $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable; $rootClass = $this->queryComponents[$rootAlias]['metadata']; $rootIdentifier = $rootClass->identifier; diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php index 342e309b1..c88191153 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php @@ -63,7 +63,8 @@ class LimitSubqueryWalker extends TreeWalkerAdapter $queryComponents = $this->_getQueryComponents(); // Get the root entity and alias from the AST fromClause $from = $AST->fromClause->identificationVariableDeclarations; - $rootAlias = $from[0]->rangeVariableDeclaration->aliasIdentificationVariable; + $fromRoot = reset($from); + $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable; $rootClass = $queryComponents[$rootAlias]['metadata']; $selectExpressions = array(); diff --git a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php index 2584b8ef9..9f42a1eea 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php @@ -79,7 +79,8 @@ class WhereInWalker extends TreeWalkerAdapter throw new \RuntimeException("Cannot count query which selects two FROM components, cannot make distinction"); } - $rootAlias = $from[0]->rangeVariableDeclaration->aliasIdentificationVariable; + $fromRoot = reset($from); + $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable; $rootClass = $queryComponents[$rootAlias]['metadata']; $identifierFieldName = $rootClass->getSingleIdentifierFieldName();