Skip to content

Commit ae76ccc

Browse files
authored
Merge pull request #3853 from BenMorel/deprecations
Deprecate calling QueryBuilder methods with an array argument
2 parents ce9b49c + ebfe185 commit ae76ccc

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

UPGRADE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ The usage of the `andX()` and `orX()` methods of the `ExpressionBuilder` class h
99
The usage of the `add()` and `addMultiple()` methods of the `CompositeExpression` class has been deprecated. Use `with()` instead, which returns a new instance.
1010
In the future, the `add*()` methods will be removed and the class will be effectively immutable.
1111

12+
## Deprecated calling `QueryBuilder` methods with an array argument
13+
14+
Calling the `select()`, `addSelect()`, `groupBy()` and `addGroupBy()` methods with an array argument is deprecated.
15+
1216
# Upgrade to 2.10
1317

1418
## Deprecated `Doctrine\DBAL\Event\ConnectionEventArgs` methods

lib/Doctrine/DBAL/Query/QueryBuilder.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -451,18 +451,21 @@ public function add($sqlPartName, $sqlPart, $append = false)
451451
* Specifies an item that is to be returned in the query result.
452452
* Replaces any previously specified selections, if any.
453453
*
454+
* USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument.
455+
*
454456
* <code>
455457
* $qb = $conn->createQueryBuilder()
456458
* ->select('u.id', 'p.id')
457459
* ->from('users', 'u')
458460
* ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
459461
* </code>
460462
*
461-
* @param mixed $select The selection expressions.
463+
* @param string|string[]|null $select The selection expression. USING AN ARRAY OR NULL IS DEPRECATED.
464+
* Pass each value as an individual argument.
462465
*
463466
* @return $this This QueryBuilder instance.
464467
*/
465-
public function select($select = null)
468+
public function select($select = null/*, string ...$selects*/)
466469
{
467470
$this->type = self::SELECT;
468471

@@ -497,6 +500,8 @@ public function distinct() : self
497500
/**
498501
* Adds an item that is to be returned in the query result.
499502
*
503+
* USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument.
504+
*
500505
* <code>
501506
* $qb = $conn->createQueryBuilder()
502507
* ->select('u.id')
@@ -505,11 +510,12 @@ public function distinct() : self
505510
* ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id');
506511
* </code>
507512
*
508-
* @param mixed $select The selection expression.
513+
* @param string|string[]|null $select The selection expression. USING AN ARRAY OR NULL IS DEPRECATED.
514+
* Pass each value as an individual argument.
509515
*
510516
* @return $this This QueryBuilder instance.
511517
*/
512-
public function addSelect($select = null)
518+
public function addSelect($select = null/*, string ...$selects*/)
513519
{
514520
$this->type = self::SELECT;
515521

@@ -869,18 +875,21 @@ public function orWhere($where)
869875
* Specifies a grouping over the results of the query.
870876
* Replaces any previously specified groupings, if any.
871877
*
878+
* USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument.
879+
*
872880
* <code>
873881
* $qb = $conn->createQueryBuilder()
874882
* ->select('u.name')
875883
* ->from('users', 'u')
876884
* ->groupBy('u.id');
877885
* </code>
878886
*
879-
* @param mixed $groupBy The grouping expression.
887+
* @param string|string[] $groupBy The grouping expression. USING AN ARRAY IS DEPRECATED.
888+
* Pass each value as an individual argument.
880889
*
881890
* @return $this This QueryBuilder instance.
882891
*/
883-
public function groupBy($groupBy)
892+
public function groupBy($groupBy/*, string ...$groupBys*/)
884893
{
885894
if (empty($groupBy)) {
886895
return $this;
@@ -894,6 +903,8 @@ public function groupBy($groupBy)
894903
/**
895904
* Adds a grouping expression to the query.
896905
*
906+
* USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument.
907+
*
897908
* <code>
898909
* $qb = $conn->createQueryBuilder()
899910
* ->select('u.name')
@@ -902,11 +913,12 @@ public function groupBy($groupBy)
902913
* ->addGroupBy('u.createdAt');
903914
* </code>
904915
*
905-
* @param mixed $groupBy The grouping expression.
916+
* @param string|string[] $groupBy The grouping expression. USING AN ARRAY IS DEPRECATED.
917+
* Pass each value as an individual argument.
906918
*
907919
* @return $this This QueryBuilder instance.
908920
*/
909-
public function addGroupBy($groupBy)
921+
public function addGroupBy($groupBy/*, string ...$groupBys*/)
910922
{
911923
if (empty($groupBy)) {
912924
return $this;

0 commit comments

Comments
 (0)