summaryrefslogtreecommitdiffstats
path: root/src/Components/Condition.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Components/Condition.php')
-rw-r--r--src/Components/Condition.php36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/Components/Condition.php b/src/Components/Condition.php
index 700b071..b719b28 100644
--- a/src/Components/Condition.php
+++ b/src/Components/Condition.php
@@ -1,8 +1,8 @@
<?php
-
/**
* `WHERE` keyword parser.
*/
+declare(strict_types=1);
namespace PhpMyAdmin\SqlParser\Components;
@@ -13,10 +13,6 @@ use PhpMyAdmin\SqlParser\TokensList;
/**
* `WHERE` keyword parser.
- *
- * @category Keywords
- *
- * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
*/
class Condition extends Component
{
@@ -25,20 +21,20 @@ class Condition extends Component
*
* @var array
*/
- public static $DELIMITERS = array(
+ public static $DELIMITERS = [
'&&',
'||',
'AND',
'OR',
- 'XOR'
- );
+ 'XOR',
+ ];
/**
* List of allowed reserved keywords in conditions.
*
* @var array
*/
- public static $ALLOWED_KEYWORDS = array(
+ public static $ALLOWED_KEYWORDS = [
'ALL' => 1,
'AND' => 1,
'BETWEEN' => 1,
@@ -56,15 +52,15 @@ class Condition extends Component
'OR' => 1,
'REGEXP' => 1,
'RLIKE' => 1,
- 'XOR' => 1
- );
+ 'XOR' => 1,
+ ];
/**
* Identifiers recognized.
*
* @var array
*/
- public $identifiers = array();
+ public $identifiers = [];
/**
* Whether this component is an operator.
@@ -81,13 +77,11 @@ class Condition extends Component
public $expr;
/**
- * Constructor.
- *
* @param string $expr the condition or the operator
*/
public function __construct($expr = null)
{
- $this->expr = trim($expr);
+ $this->expr = trim((string) $expr);
}
/**
@@ -97,11 +91,11 @@ class Condition extends Component
*
* @return Condition[]
*/
- public static function parse(Parser $parser, TokensList $list, array $options = array())
+ public static function parse(Parser $parser, TokensList $list, array $options = [])
{
- $ret = array();
+ $ret = [];
- $expr = new self();
+ $expr = new static();
/**
* Counts brackets.
@@ -159,12 +153,12 @@ class Condition extends Component
}
// Adding the operator.
- $expr = new self($token->value);
+ $expr = new static($token->value);
$expr->isOperator = true;
$ret[] = $expr;
// Preparing to parse another condition.
- $expr = new self();
+ $expr = new static();
continue;
}
}
@@ -222,7 +216,7 @@ class Condition extends Component
*
* @return string
*/
- public static function build($component, array $options = array())
+ public static function build($component, array $options = [])
{
if (is_array($component)) {
return implode(' ', $component);