-
-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow use array and multi arguments #100
Changes from 5 commits
f222b74
1d59e5d
19f15af
9d8b491
6bd6a40
37494e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
language: php | ||
|
||
php: | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- hhvm | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ class ExpressionBuilder | |
*/ | ||
public function andX($x = null) | ||
{ | ||
return new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args()); | ||
return new CompositeExpression(CompositeExpression::TYPE_AND, is_array($x) ? $x : func_get_args()); | ||
} | ||
|
||
/** | ||
|
@@ -52,7 +52,7 @@ public function andX($x = null) | |
*/ | ||
public function orX($x = null) | ||
{ | ||
return new CompositeExpression(CompositeExpression::TYPE_OR, func_get_args()); | ||
return new CompositeExpression(CompositeExpression::TYPE_OR, is_array($x) ? $x : func_get_args()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be changed to just accept |
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,46 @@ public function testOrX() | |
$this->assertEquals(CompositeExpression::TYPE_OR, $expr->getType()); | ||
} | ||
|
||
public function testAndXArguments() | ||
{ | ||
$x = [ | ||
$this->builder->eq("a", "b"), | ||
$this->builder->eq("c", "d"), | ||
]; | ||
|
||
$expr = $this->builder->andX( | ||
$x[0], | ||
$x[1] | ||
); | ||
$this->assertEquals($x, $expr->getExpressionList()); | ||
|
||
$expr = $this->builder->andX($x); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems invalid to me |
||
$this->assertEquals($x, $expr->getExpressionList()); | ||
|
||
$expr = $this->builder->andX(...$x); | ||
$this->assertEquals($x, $expr->getExpressionList()); | ||
} | ||
|
||
public function testOrXArguments() | ||
{ | ||
$x = [ | ||
$this->builder->eq("a", "b"), | ||
$this->builder->eq("c", "d"), | ||
]; | ||
|
||
$expr = $this->builder->orX( | ||
$x[0], | ||
$x[1] | ||
); | ||
$this->assertEquals($x, $expr->getExpressionList()); | ||
|
||
$expr = $this->builder->orX($x); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems invalid to me |
||
$this->assertEquals($x, $expr->getExpressionList()); | ||
|
||
$expr = $this->builder->orX(...$x); | ||
$this->assertEquals($x, $expr->getExpressionList()); | ||
} | ||
|
||
public function testInvalidAndXArgument() | ||
{ | ||
$this->setExpectedException("RuntimeException"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be changed to just accept
$x
, and the method signature should become...$x