Skip to content

Commit

Permalink
[doctrineGH-3837] Trigger deprecation for QueryBuilder::select/addSel…
Browse files Browse the repository at this point in the history
…ect/groupBy/addGroupBy with array argument.
  • Loading branch information
beberlei committed Mar 11, 2021
1 parent 5d20e3c commit 9981c03
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions lib/Doctrine/DBAL/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Doctrine\DBAL\Query\Expression\CompositeExpression;
use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
use Doctrine\DBAL\Types\Type;
use Doctrine\Deprecations\Deprecation;

use function array_filter;
use function array_key_exists;
Expand Down Expand Up @@ -483,6 +484,15 @@ public function select($select = null/*, string ...$selects*/)
return $this;
}

if (is_array($select)) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3837',
'Passing an array for the first argument to QueryBuilder::select is deprecated, ' .
'pass each value as an individual variadic argument instead.'
);
}

$selects = is_array($select) ? $select : func_get_args();

return $this->add('select', $selects);
Expand Down Expand Up @@ -533,6 +543,15 @@ public function addSelect($select = null/*, string ...$selects*/)
return $this;
}

if (is_array($select)) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3837',
'Passing an array for the first argument to QueryBuilder::addSelect is deprecated, ' .
'pass each value as an individual variadic argument instead.'
);
}

$selects = is_array($select) ? $select : func_get_args();

return $this->add('select', $selects, true);
Expand Down Expand Up @@ -911,6 +930,15 @@ public function groupBy($groupBy/*, string ...$groupBys*/)
return $this;
}

if (is_array($groupBy)) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3837',
'Passing an array for the first argument to QueryBuilder::groupBy is deprecated, ' .
'pass each value as an individual variadic argument instead.'
);
}

$groupBy = is_array($groupBy) ? $groupBy : func_get_args();

return $this->add('groupBy', $groupBy, false);
Expand Down Expand Up @@ -940,6 +968,15 @@ public function addGroupBy($groupBy/*, string ...$groupBys*/)
return $this;
}

if (is_array($groupBy)) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3837',
'Passing an array for the first argument to QueryBuilder::addGroupBy is deprecated, ' .
'pass each value as an individual variadic argument instead.'
);
}

$groupBy = is_array($groupBy) ? $groupBy : func_get_args();

return $this->add('groupBy', $groupBy, true);
Expand Down

0 comments on commit 9981c03

Please sign in to comment.