Skip to content

Commit

Permalink
Fix build with PHP 5.6.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgaillard committed Nov 28, 2017
1 parent 47b36b9 commit 42e5703
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/main/php/Gomoob/Filter/Sql/SqlFilterConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,8 @@ private function transformComplexFilter(

// If a logical expression is expressed
if (count($tokens) === 3 &&
($tokens[1]->getTokenCode() === LogicOperatorToken::AND ||
$tokens[1]->getTokenCode() === LogicOperatorToken::OR)) {
($tokens[1]->getTokenCode() === LogicOperatorToken::AND_OPERATOR ||
$tokens[1]->getTokenCode() === LogicOperatorToken::OR_OPERATOR)) {
// Transform the first part of the logical expression
$sqlFilter1 = $this->transformSimpleFilter($key, $tokens[0]->getSequence(), $context);

Expand All @@ -543,9 +543,9 @@ private function transformComplexFilter(
// Creates the resulting SQL logical expression
$result[0] = $sqlFilter1->getExpression();

if ($tokens[1]->getTokenCode() === LogicOperatorToken::AND) {
if ($tokens[1]->getTokenCode() === LogicOperatorToken::AND_OPERATOR) {
$result[0] .= ' AND ';
} elseif ($tokens[1]->getTokenCode() === LogicOperatorToken::OR) {
} elseif ($tokens[1]->getTokenCode() === LogicOperatorToken::OR_OPERATOR) {
$result[0] .= ' OR ';
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/php/Gomoob/Filter/Tokenizer/LogicOperatorToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@
*/
class LogicOperatorToken extends Token
{

/**
* Token code associated to the '+' terminal.
*/
const AND = 1;
const AND_OPERATOR = 1;

/**
* Token code associated to an integer or float number terminal.
Expand All @@ -48,7 +47,7 @@ class LogicOperatorToken extends Token
/**
* Token code associated to the '-' terminal.
*/
const OR = 3;
const OR_OPERATOR = 3;

/**
* Token code associated to a string terminal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public function __construct()
// WARNING, ORDER IS VERY IMPORTANT

// Logic operator
$this->addTokenInfo('(\+)', LogicOperatorToken::AND);
$this->addTokenInfo('(-)', LogicOperatorToken::OR);
$this->addTokenInfo('(\+)', LogicOperatorToken::AND_OPERATOR);
$this->addTokenInfo('(-)', LogicOperatorToken::OR_OPERATOR);

// "Raw" values
$this->addTokenInfo('([0-9.]+)', LogicOperatorToken::NUMBER);
Expand Down

0 comments on commit 42e5703

Please sign in to comment.