Skip to content

Commit 4434d39

Browse files
committed
Replace andX/orX with and/or
1 parent c2b8e6e commit 4434d39

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

UPGRADE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Upgrade to 2.11
2+
3+
## Deprecated `ExpressionBuilder` methods
4+
5+
The usage of the `andX()` and `orX()` methods of the `ExpressionBuilder` class has been deprecated. Use `and()` and `or()` instead.
6+
17
# Upgrade to 2.10
28

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

lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __construct(Connection $connection)
5252
*
5353
* @return CompositeExpression
5454
*/
55-
public function andX($x = null)
55+
public function and($x = null)
5656
{
5757
return new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args());
5858
}
@@ -71,6 +71,32 @@ public function andX($x = null)
7171
*
7272
* @return CompositeExpression
7373
*/
74+
public function or($x = null)
75+
{
76+
return new CompositeExpression(CompositeExpression::TYPE_OR, func_get_args());
77+
}
78+
79+
/**
80+
* @deprecated Use `and()` instead.
81+
*
82+
* @param mixed $x Optional clause. Defaults = null, but requires
83+
* at least one defined when converting to string.
84+
*
85+
* @return CompositeExpression
86+
*/
87+
public function andX($x = null)
88+
{
89+
return new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args());
90+
}
91+
92+
/**
93+
* @deprecated Use `and()` instead.
94+
*
95+
* @param mixed $x Optional clause. Defaults = null, but requires
96+
* at least one defined when converting to string.
97+
*
98+
* @return CompositeExpression
99+
*/
74100
public function orX($x = null)
75101
{
76102
return new CompositeExpression(CompositeExpression::TYPE_OR, func_get_args());

tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function setUp() : void
3333
*/
3434
public function testAndX(array $parts, string $expected) : void
3535
{
36-
$composite = $this->expr->andX();
36+
$composite = $this->expr->and();
3737

3838
foreach ($parts as $part) {
3939
$composite->add($part);
@@ -94,7 +94,7 @@ public static function provideDataForAndX() : iterable
9494
*/
9595
public function testOrX(array $parts, string $expected) : void
9696
{
97-
$composite = $this->expr->orX();
97+
$composite = $this->expr->or();
9898

9999
foreach ($parts as $part) {
100100
$composite->add($part);

tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testSelectWithSimpleWhere() : void
6868

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

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

0 commit comments

Comments
 (0)