Skip to content

Commit

Permalink
Replace andX/orX with and/or
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Jan 27, 2020
1 parent c2b8e6e commit 4434d39
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
6 changes: 6 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Upgrade to 2.11

## Deprecated `ExpressionBuilder` methods

The usage of the `andX()` and `orX()` methods of the `ExpressionBuilder` class has been deprecated. Use `and()` and `or()` instead.

# Upgrade to 2.10

## Deprecated `Doctrine\DBAL\Event\ConnectionEventArgs` methods
Expand Down
28 changes: 27 additions & 1 deletion lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct(Connection $connection)
*
* @return CompositeExpression
*/
public function andX($x = null)
public function and($x = null)
{
return new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args());
}
Expand All @@ -71,6 +71,32 @@ public function andX($x = null)
*
* @return CompositeExpression
*/
public function or($x = null)
{
return new CompositeExpression(CompositeExpression::TYPE_OR, func_get_args());
}

/**
* @deprecated Use `and()` instead.
*
* @param mixed $x Optional clause. Defaults = null, but requires
* at least one defined when converting to string.
*
* @return CompositeExpression
*/
public function andX($x = null)
{
return new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args());
}

/**
* @deprecated Use `and()` instead.
*
* @param mixed $x Optional clause. Defaults = null, but requires
* at least one defined when converting to string.
*
* @return CompositeExpression
*/
public function orX($x = null)
{
return new CompositeExpression(CompositeExpression::TYPE_OR, func_get_args());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function setUp() : void
*/
public function testAndX(array $parts, string $expected) : void
{
$composite = $this->expr->andX();
$composite = $this->expr->and();

foreach ($parts as $part) {
$composite->add($part);
Expand Down Expand Up @@ -94,7 +94,7 @@ public static function provideDataForAndX() : iterable
*/
public function testOrX(array $parts, string $expected) : void
{
$composite = $this->expr->orX();
$composite = $this->expr->or();

foreach ($parts as $part) {
$composite->add($part);
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function testSelectWithSimpleWhere() : void

$qb->select('u.id')
->from('users', 'u')
->where($expr->andX($expr->eq('u.nickname', '?')));
->where($expr->and($expr->eq('u.nickname', '?')));

self::assertEquals('SELECT u.id FROM users u WHERE u.nickname = ?', (string) $qb);
}
Expand Down

0 comments on commit 4434d39

Please sign in to comment.