@@ -208,8 +208,8 @@ discard block  | 
                                                    ||
| 208 | 208 | $sqlIdentifier = $this->getSQLIdentifier($AST);  | 
                                                        
| 209 | 209 | |
| 210 | 210 |          if ($hasOrderBy) { | 
                                                        
| 211 | -            $orderGroupBy = ' GROUP BY ' . implode(', ', $sqlIdentifier); | 
                                                        |
| 212 | -            $sqlIdentifier[] = 'MIN(' . $this->walkResultVariable('dctrn_rownum') . ') AS dctrn_minrownum'; | 
                                                        |
| 211 | +            $orderGroupBy = ' GROUP BY '.implode(', ', $sqlIdentifier); | 
                                                        |
| 212 | +            $sqlIdentifier[] = 'MIN('.$this->walkResultVariable('dctrn_rownum').') AS dctrn_minrownum'; | 
                                                        |
| 213 | 213 | }  | 
                                                        
| 214 | 214 | |
| 215 | 215 | // Build the counter query  | 
                                                        
@@ -220,7 +220,7 @@ discard block  | 
                                                    ||
| 220 | 220 | );  | 
                                                        
| 221 | 221 | |
| 222 | 222 |          if ($hasOrderBy) { | 
                                                        
| 223 | - $sql .= $orderGroupBy . $outerOrderBy;  | 
                                                        |
| 223 | + $sql .= $orderGroupBy.$outerOrderBy;  | 
                                                        |
| 224 | 224 | }  | 
                                                        
| 225 | 225 | |
| 226 | 226 | // Apply the limit and offset.  | 
                                                        
@@ -323,7 +323,7 @@ discard block  | 
                                                    ||
| 323 | 323 |          foreach ($orderByPathExpressions as $pathExpression) { | 
                                                        
| 324 | 324 | $idVar = $pathExpression->identificationVariable;  | 
                                                        
| 325 | 325 | $field = $pathExpression->field;  | 
                                                        
| 326 | -            if (!isset($selects[$idVar])) { | 
                                                        |
| 326 | +            if ( ! isset($selects[$idVar])) { | 
                                                        |
| 327 | 327 | $selects[$idVar] = [];  | 
                                                        
| 328 | 328 | }  | 
                                                        
| 329 | 329 | $selects[$idVar][$field] = true;  | 
                                                        
@@ -334,7 +334,7 @@ discard block  | 
                                                    ||
| 334 | 334 |          foreach ($AST->selectClause->selectExpressions as $selectExpression) { | 
                                                        
| 335 | 335 |              if ($selectExpression instanceof SelectExpression) { | 
                                                        
| 336 | 336 | $idVar = $selectExpression->expression;  | 
                                                        
| 337 | -                if (!is_string($idVar)) { | 
                                                        |
| 337 | +                if ( ! is_string($idVar)) { | 
                                                        |
| 338 | 338 | continue;  | 
                                                        
| 339 | 339 | }  | 
                                                        
| 340 | 340 | $field = $selectExpression->fieldIdentificationVariable;  | 
                                                        
@@ -367,10 +367,10 @@ discard block  | 
                                                    ||
| 367 | 367 | array $sqlIdentifier,  | 
                                                        
| 368 | 368 | string $innerSql,  | 
                                                        
| 369 | 369 | string $sql,  | 
                                                        
| 370 | - ?OrderByClause $orderByClause  | 
                                                        |
| 370 | + ? OrderByClause $orderByClause  | 
                                                        |
| 371 | 371 |      ) : string { | 
                                                        
| 372 | 372 | // If the sql statement has an order by clause, we need to wrap it in a new select distinct statement  | 
                                                        
| 373 | -        if (! $orderByClause) { | 
                                                        |
| 373 | +        if ( ! $orderByClause) { | 
                                                        |
| 374 | 374 | return $sql;  | 
                                                        
| 375 | 375 | }  | 
                                                        
| 376 | 376 | |
@@ -412,7 +412,7 @@ discard block  | 
                                                    ||
| 412 | 412 | $orderByItems[] = $orderByItemString;  | 
                                                        
| 413 | 413 | $identifier = \substr($orderByItemString, 0, \strrpos($orderByItemString, ' '));  | 
                                                        
| 414 | 414 | |
| 415 | -            if (! \in_array($identifier, $identifiers, true)) { | 
                                                        |
| 415 | +            if ( ! \in_array($identifier, $identifiers, true)) { | 
                                                        |
| 416 | 416 | $identifiers[] = $identifier;  | 
                                                        
| 417 | 417 | }  | 
                                                        
| 418 | 418 | }  | 
                                                        
@@ -444,7 +444,7 @@ discard block  | 
                                                    ||
| 444 | 444 | $class = $metadataList[$dqlAliasForFieldAlias];  | 
                                                        
| 445 | 445 | |
| 446 | 446 | // If the field is from a joined child table, we won't be ordering on it.  | 
                                                        
| 447 | -            if (! isset($class->fieldMappings[$fieldName])) { | 
                                                        |
| 447 | +            if ( ! isset($class->fieldMappings[$fieldName])) { | 
                                                        |
| 448 | 448 | continue;  | 
                                                        
| 449 | 449 | }  | 
                                                        
| 450 | 450 | |
@@ -465,7 +465,7 @@ discard block  | 
                                                    ||
| 465 | 465 | // for the joined parent table.  | 
                                                        
| 466 | 466 | $otherClassMetadata = $this->em->getClassMetadata($fieldMapping['declared']);  | 
                                                        
| 467 | 467 | |
| 468 | -                if (! $otherClassMetadata->isMappedSuperclass) { | 
                                                        |
| 468 | +                if ( ! $otherClassMetadata->isMappedSuperclass) { | 
                                                        |
| 469 | 469 | $sqlTableAliasForFieldAlias = $this->getSQLTableAlias($otherClassMetadata->getTableName(), $dqlAliasForFieldAlias);  | 
                                                        
| 470 | 470 | }  | 
                                                        
| 471 | 471 | }  | 
                                                        
@@ -582,7 +582,7 @@ discard block  | 
                                                    ||
| 582 | 582 | */  | 
                                                        
| 583 | 583 | public function walkPathExpression($pathExpr)  | 
                                                        
| 584 | 584 |      { | 
                                                        
| 585 | -        if (!$this->inSubSelect && !$this->platformSupportsRowNumber() && !in_array($pathExpr, $this->orderByPathExpressions)) { | 
                                                        |
| 585 | +        if ( ! $this->inSubSelect && ! $this->platformSupportsRowNumber() && ! in_array($pathExpr, $this->orderByPathExpressions)) { | 
                                                        |
| 586 | 586 | $this->orderByPathExpressions[] = $pathExpr;  | 
                                                        
| 587 | 587 | }  | 
                                                        
| 588 | 588 | |