diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php
index 02eaeeaa5..3943cb5e6 100644
--- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php
+++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php
@@ -179,16 +179,14 @@ class LimitSubqueryOutputWalker extends SqlWalker
         $orderBy         = array();
         if (isset($AST->orderByClause)) {
             foreach ($AST->orderByClause->orderByItems as $item) {
-                if (is_object($item->expression)) {
-                    $possibleAliases = array_keys($this->rsm->fieldMappings, $item->expression->field);
-                } else {
-                    $possibleAliases = array_keys($this->rsm->scalarMappings, $item->expression);
-                }
+                $possibleAliases = (is_object($item->expression))
+                    ? array_keys($this->rsm->fieldMappings, $item->expression->field)
+                    : array_keys($this->rsm->scalarMappings, $item->expression);
 
                 foreach ($possibleAliases as $alias) {
                     if (!is_object($item->expression) || $this->rsm->columnOwnerMap[$alias] == $item->expression->identificationVariable) {
                         $sqlOrderColumns[] = $alias;
-                        $orderBy[] = $alias . ' ' . $item->type;
+                        $orderBy[]         = $alias . ' ' . $item->type;
                         break;
                     }
                 }
diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php
index 6d8355525..bb69cd310 100644
--- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php
+++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php
@@ -42,7 +42,7 @@ class LimitSubqueryOutputWalkerTest extends PaginationTestCase
         $this->entityManager->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform);
 
         $query = $this->entityManager->createQuery(
-            'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\USER u JOIN u.groups g ORDER BY g_quantity'
+            'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity'
         );
         $limitQuery = clone $query;
         $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker');