-
Notifications
You must be signed in to change notification settings - Fork 9
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
Chain multiple comparision expressions #6
base: master
Are you sure you want to change the base?
Changes from all commits
f27ee49
706c213
6e988b7
273d783
9f816d6
bd99029
5562478
5799fd1
4ce3dce
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 |
---|---|---|
|
@@ -13,11 +13,11 @@ | |
|
||
class Disjunction extends Filter | ||
{ | ||
/** @var Term[] */ | ||
/** @var Filter[] */ | ||
private $terms = []; | ||
|
||
/** | ||
* @param Term[] $terms | ||
* @param Filter[] $terms | ||
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. Same goes for this one, I would rename to |
||
*/ | ||
public function __construct(array $terms = []) | ||
{ | ||
|
@@ -27,15 +27,15 @@ public function __construct(array $terms = []) | |
} | ||
|
||
/** | ||
* @param Term $term | ||
* @param Filter $term | ||
*/ | ||
public function add(Term $term) | ||
public function add(Filter $term) | ||
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. Same goes for this one, I would rename to |
||
{ | ||
$this->terms[] = $term; | ||
} | ||
|
||
/** | ||
* @return Term[] | ||
* @return Filter[] | ||
*/ | ||
public function getTerms() | ||
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. Assuming changing this from |
||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,4 +64,20 @@ public function dump() | |
return array_merge($this->valuePath->dump(), $this->attributePath->dump()); | ||
} | ||
} | ||
|
||
/** | ||
* @return AttributePath | ||
*/ | ||
public function getAttributePath() | ||
{ | ||
return $this->attributePath; | ||
} | ||
|
||
/** | ||
* @return ValuePath | ||
*/ | ||
public function getValuePath() | ||
{ | ||
return $this->valuePath; | ||
} | ||
Comment on lines
+67
to
+82
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. There's already a pending PR for this one: #7 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,13 +127,16 @@ private function disjunction() | |
$terms = []; | ||
$terms[] = $this->conjunction(); | ||
|
||
if ($this->lexer->isNextToken(Tokens::T_SP)) { | ||
$isNextTokenOr = true; | ||
while($this->lexer->isNextToken(Tokens::T_SP) && $isNextTokenOr) { | ||
$nextToken = $this->lexer->glimpse(); | ||
if ($this->isName('or', $nextToken)) { | ||
$this->match(Tokens::T_SP); | ||
$this->match(Tokens::T_NAME); | ||
$this->match(Tokens::T_SP); | ||
$terms[] = $this->conjunction(); | ||
} else { | ||
$isNextTokenOr = false; | ||
} | ||
} | ||
Comment on lines
-130
to
141
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. Instead of using a variable to break the while ($this->lexer->isNextToken(Tokens::T_SP)) {
$nextToken = $this->lexer->glimpse();
if ($this->isName('or', $nextToken) === false) {
break;
}
$this->match(Tokens::T_SP);
$this->match(Tokens::T_NAME);
$this->match(Tokens::T_SP);
$terms[] = $this->conjunction();
} |
||
|
||
|
@@ -152,13 +155,16 @@ private function conjunction() | |
$factors = []; | ||
$factors[] = $this->factor(); | ||
|
||
if ($this->lexer->isNextToken(Tokens::T_SP)) { | ||
$isNextTokenAnd = true; | ||
while($this->lexer->isNextToken(Tokens::T_SP) && $isNextTokenAnd) { | ||
$nextToken = $this->lexer->glimpse(); | ||
if ($this->isName('and', $nextToken)) { | ||
$this->match(Tokens::T_SP); | ||
$this->match(Tokens::T_NAME); | ||
$this->match(Tokens::T_SP); | ||
$factors[] = $this->factor(); | ||
} else { | ||
$isNextTokenAnd = false; | ||
} | ||
} | ||
Comment on lines
-155
to
169
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. Same goes for this one: while ($this->lexer->isNextToken(Tokens::T_SP)) {
$nextToken = $this->lexer->glimpse();
if ($this->isName('and', $nextToken) === false) {
break;
}
$this->match(Tokens::T_SP);
$this->match(Tokens::T_NAME);
$this->match(Tokens::T_SP);
$factors[] = $this->factor();
} |
||
|
||
|
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.
I would rename this to
$filters
.