summaryrefslogtreecommitdiffstats
path: root/src/Components/OptionsArray.php
diff options
context:
space:
mode:
authorMaurício Meneghini Fauth <mauriciofauth@gmail.com>2019-01-08 21:32:02 -0200
committerMaurício Meneghini Fauth <mauriciofauth@gmail.com>2019-01-16 17:21:25 -0200
commit86c5baebda24c1721fb6881df8671a3c7df60e8b (patch)
tree0a76d58ea229d1008e169b1c5b25ce90dde91808 /src/Components/OptionsArray.php
parent28427543566b6dd32fe44db704ea41368ba55c0e (diff)
downloadsql-parser-86c5baebda24c1721fb6881df8671a3c7df60e8b.zip
sql-parser-86c5baebda24c1721fb6881df8671a3c7df60e8b.tar.gz
sql-parser-86c5baebda24c1721fb6881df8671a3c7df60e8b.tar.bz2
Apply phpmyadmin/coding-standard
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
Diffstat (limited to 'src/Components/OptionsArray.php')
-rw-r--r--src/Components/OptionsArray.php38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/Components/OptionsArray.php b/src/Components/OptionsArray.php
index fd02d22..2b17cdd 100644
--- a/src/Components/OptionsArray.php
+++ b/src/Components/OptionsArray.php
@@ -26,7 +26,7 @@ class OptionsArray extends Component
*
* @var array
*/
- public $options = array();
+ public $options = [];
/**
* Constructor.
@@ -35,7 +35,7 @@ class OptionsArray extends Component
* must be an array with at least two keys `name` and
* `expr` or `value`.
*/
- public function __construct(array $options = array())
+ public function __construct(array $options = [])
{
$this->options = $options;
}
@@ -47,7 +47,7 @@ class OptionsArray extends Component
*
* @return OptionsArray
*/
- public static function parse(Parser $parser, TokensList $list, array $options = array())
+ public static function parse(Parser $parser, TokensList $list, array $options = [])
{
$ret = new self();
@@ -156,7 +156,7 @@ class OptionsArray extends Component
}
if ($state === 0) {
- if (!is_array($lastOption)) {
+ if (! is_array($lastOption)) {
// This is a just keyword option without any value.
// This is the beginning and the end of it.
$ret->options[$lastOptionId] = $token->value;
@@ -167,7 +167,7 @@ class OptionsArray extends Component
// This is only the beginning. The value is parsed in state
// 1 and 2. State 1 is used to skip the first equals sign
// and state 2 to parse the actual value.
- $ret->options[$lastOptionId] = array(
+ $ret->options[$lastOptionId] = [
// @var string The name of the option.
'name' => $token->value,
// @var bool Whether it contains an equal sign.
@@ -177,7 +177,7 @@ class OptionsArray extends Component
'expr' => '',
// @var string Processed value.
'value' => '',
- );
+ ];
$state = 1;
} elseif ($lastOption[1] === 'expr' || $lastOption[1] === 'expr=') {
// This is a keyword that is followed by an expression.
@@ -185,7 +185,7 @@ class OptionsArray extends Component
// Skipping this option in order to parse the expression.
++$list->idx;
- $ret->options[$lastOptionId] = array(
+ $ret->options[$lastOptionId] = [
// @var string The name of the option.
'name' => $token->value,
// @var bool Whether it contains an equal sign.
@@ -193,7 +193,7 @@ class OptionsArray extends Component
'equals' => $lastOption[1] === 'expr=',
// @var Expression The parsed expression.
'expr' => '',
- );
+ ];
$state = 1;
}
} elseif ($state === 1) {
@@ -211,7 +211,7 @@ class OptionsArray extends Component
$ret->options[$lastOptionId]['expr'] = Expression::parse(
$parser,
$list,
- empty($lastOption[2]) ? array() : $lastOption[2]
+ empty($lastOption[2]) ? [] : $lastOption[2]
);
$ret->options[$lastOptionId]['value']
= $ret->options[$lastOptionId]['expr']->expr;
@@ -226,7 +226,7 @@ class OptionsArray extends Component
$ret->options[$lastOptionId]['expr'] .= $token->token;
- if (!((($token->token === '(') && ($brackets === 1))
+ if (! ((($token->token === '(') && ($brackets === 1))
|| (($token->token === ')') && ($brackets === 0)))
) {
// First pair of brackets is being skipped.
@@ -276,20 +276,20 @@ class OptionsArray extends Component
*
* @return string
*/
- public static function build($component, array $options = array())
+ public static function build($component, array $options = [])
{
if (empty($component->options)) {
return '';
}
- $options = array();
+ $options = [];
foreach ($component->options as $option) {
- if (!is_array($option)) {
+ if (! is_array($option)) {
$options[] = $option;
} else {
$options[] = $option['name']
- . ((!empty($option['equals']) && $option['equals']) ? '=' : ' ')
- . (!empty($option['expr']) ? $option['expr'] : $option['value']);
+ . ((! empty($option['equals']) && $option['equals']) ? '=' : ' ')
+ . (! empty($option['expr']) ? $option['expr'] : $option['value']);
}
}
@@ -309,10 +309,10 @@ class OptionsArray extends Component
{
foreach ($this->options as $option) {
if (is_array($option)) {
- if (!strcasecmp($key, $option['name'])) {
+ if (! strcasecmp($key, $option['name'])) {
return $getExpr ? $option['expr'] : $option['value'];
}
- } elseif (!strcasecmp($key, $option)) {
+ } elseif (! strcasecmp($key, $option)) {
return true;
}
}
@@ -331,12 +331,12 @@ class OptionsArray extends Component
{
foreach ($this->options as $idx => $option) {
if (is_array($option)) {
- if (!strcasecmp($key, $option['name'])) {
+ if (! strcasecmp($key, $option['name'])) {
unset($this->options[$idx]);
return true;
}
- } elseif (!strcasecmp($key, $option)) {
+ } elseif (! strcasecmp($key, $option)) {
unset($this->options[$idx]);
return true;