Unverified Commit ae76cccb authored by Sergei Morozov's avatar Sergei Morozov Committed by GitHub

Merge pull request #3853 from BenMorel/deprecations

Deprecate calling QueryBuilder methods with an array argument
parents ce9b49c4 ebfe1851
...@@ -9,6 +9,10 @@ The usage of the `andX()` and `orX()` methods of the `ExpressionBuilder` class h ...@@ -9,6 +9,10 @@ The usage of the `andX()` and `orX()` methods of the `ExpressionBuilder` class h
The usage of the `add()` and `addMultiple()` methods of the `CompositeExpression` class has been deprecated. Use `with()` instead, which returns a new instance. The usage of the `add()` and `addMultiple()` methods of the `CompositeExpression` class has been deprecated. Use `with()` instead, which returns a new instance.
In the future, the `add*()` methods will be removed and the class will be effectively immutable. In the future, the `add*()` methods will be removed and the class will be effectively immutable.
## Deprecated calling `QueryBuilder` methods with an array argument
Calling the `select()`, `addSelect()`, `groupBy()` and `addGroupBy()` methods with an array argument is deprecated.
# Upgrade to 2.10 # Upgrade to 2.10
## Deprecated `Doctrine\DBAL\Event\ConnectionEventArgs` methods ## Deprecated `Doctrine\DBAL\Event\ConnectionEventArgs` methods
......
...@@ -451,6 +451,8 @@ class QueryBuilder ...@@ -451,6 +451,8 @@ class QueryBuilder
* Specifies an item that is to be returned in the query result. * Specifies an item that is to be returned in the query result.
* Replaces any previously specified selections, if any. * Replaces any previously specified selections, if any.
* *
* USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument.
*
* <code> * <code>
* $qb = $conn->createQueryBuilder() * $qb = $conn->createQueryBuilder()
* ->select('u.id', 'p.id') * ->select('u.id', 'p.id')
...@@ -458,11 +460,12 @@ class QueryBuilder ...@@ -458,11 +460,12 @@ class QueryBuilder
* ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id'); * ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
* </code> * </code>
* *
* @param mixed $select The selection expressions. * @param string|string[]|null $select The selection expression. USING AN ARRAY OR NULL IS DEPRECATED.
* Pass each value as an individual argument.
* *
* @return $this This QueryBuilder instance. * @return $this This QueryBuilder instance.
*/ */
public function select($select = null) public function select($select = null/*, string ...$selects*/)
{ {
$this->type = self::SELECT; $this->type = self::SELECT;
...@@ -497,6 +500,8 @@ class QueryBuilder ...@@ -497,6 +500,8 @@ class QueryBuilder
/** /**
* Adds an item that is to be returned in the query result. * Adds an item that is to be returned in the query result.
* *
* USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument.
*
* <code> * <code>
* $qb = $conn->createQueryBuilder() * $qb = $conn->createQueryBuilder()
* ->select('u.id') * ->select('u.id')
...@@ -505,11 +510,12 @@ class QueryBuilder ...@@ -505,11 +510,12 @@ class QueryBuilder
* ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id'); * ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id');
* </code> * </code>
* *
* @param mixed $select The selection expression. * @param string|string[]|null $select The selection expression. USING AN ARRAY OR NULL IS DEPRECATED.
* Pass each value as an individual argument.
* *
* @return $this This QueryBuilder instance. * @return $this This QueryBuilder instance.
*/ */
public function addSelect($select = null) public function addSelect($select = null/*, string ...$selects*/)
{ {
$this->type = self::SELECT; $this->type = self::SELECT;
...@@ -869,6 +875,8 @@ class QueryBuilder ...@@ -869,6 +875,8 @@ class QueryBuilder
* Specifies a grouping over the results of the query. * Specifies a grouping over the results of the query.
* Replaces any previously specified groupings, if any. * Replaces any previously specified groupings, if any.
* *
* USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument.
*
* <code> * <code>
* $qb = $conn->createQueryBuilder() * $qb = $conn->createQueryBuilder()
* ->select('u.name') * ->select('u.name')
...@@ -876,11 +884,12 @@ class QueryBuilder ...@@ -876,11 +884,12 @@ class QueryBuilder
* ->groupBy('u.id'); * ->groupBy('u.id');
* </code> * </code>
* *
* @param mixed $groupBy The grouping expression. * @param string|string[] $groupBy The grouping expression. USING AN ARRAY IS DEPRECATED.
* Pass each value as an individual argument.
* *
* @return $this This QueryBuilder instance. * @return $this This QueryBuilder instance.
*/ */
public function groupBy($groupBy) public function groupBy($groupBy/*, string ...$groupBys*/)
{ {
if (empty($groupBy)) { if (empty($groupBy)) {
return $this; return $this;
...@@ -894,6 +903,8 @@ class QueryBuilder ...@@ -894,6 +903,8 @@ class QueryBuilder
/** /**
* Adds a grouping expression to the query. * Adds a grouping expression to the query.
* *
* USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument.
*
* <code> * <code>
* $qb = $conn->createQueryBuilder() * $qb = $conn->createQueryBuilder()
* ->select('u.name') * ->select('u.name')
...@@ -902,11 +913,12 @@ class QueryBuilder ...@@ -902,11 +913,12 @@ class QueryBuilder
* ->addGroupBy('u.createdAt'); * ->addGroupBy('u.createdAt');
* </code> * </code>
* *
* @param mixed $groupBy The grouping expression. * @param string|string[] $groupBy The grouping expression. USING AN ARRAY IS DEPRECATED.
* Pass each value as an individual argument.
* *
* @return $this This QueryBuilder instance. * @return $this This QueryBuilder instance.
*/ */
public function addGroupBy($groupBy) public function addGroupBy($groupBy/*, string ...$groupBys*/)
{ {
if (empty($groupBy)) { if (empty($groupBy)) {
return $this; return $this;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment