summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurício Meneghini Fauth <mauricio@fauth.dev>2019-12-14 11:21:45 -0300
committerMaurício Meneghini Fauth <mauricio@fauth.dev>2019-12-14 11:21:45 -0300
commitdac2971cef5b6c71a4a52a81e116942cea704653 (patch)
treeaf2e1475eb1e2fde6977164b3e69cb8ef8c933a1
parent9d3d3b3e39162a8b5329e7a446b2f359b6e99c9d (diff)
downloadsql-parser-dac2971cef5b6c71a4a52a81e116942cea704653.zip
sql-parser-dac2971cef5b6c71a4a52a81e116942cea704653.tar.gz
sql-parser-dac2971cef5b6c71a4a52a81e116942cea704653.tar.bz2
Remove useless parentheses
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
-rw-r--r--src/Components/AlterOperation.php2
-rw-r--r--src/Components/ArrayObj.php2
-rw-r--r--src/Components/DataType.php2
-rw-r--r--src/Components/Key.php2
-rw-r--r--src/Components/OptionsArray.php2
-rw-r--r--src/Components/PartitionDefinition.php2
-rw-r--r--src/Context.php4
-rw-r--r--src/Statement.php2
-rw-r--r--src/Statements/CreateStatement.php2
-rw-r--r--src/Token.php2
-rw-r--r--src/Utils/Misc.php6
-rw-r--r--src/Utils/Query.php4
-rw-r--r--tests/Utils/CLITest.php6
-rw-r--r--tools/TestGenerator.php4
14 files changed, 20 insertions, 22 deletions
diff --git a/src/Components/AlterOperation.php b/src/Components/AlterOperation.php
index b3de878..e0c0e0b 100644
--- a/src/Components/AlterOperation.php
+++ b/src/Components/AlterOperation.php
@@ -318,7 +318,7 @@ class AlterOperation extends Component
public static function build($component, array $options = [])
{
$ret = $component->options . ' ';
- if ((isset($component->field)) && ($component->field !== '')) {
+ if (isset($component->field) && ($component->field !== '')) {
$ret .= $component->field . ' ';
}
$ret .= TokensList::build($component->unknown);
diff --git a/src/Components/ArrayObj.php b/src/Components/ArrayObj.php
index 6b90a3f..2d10ff1 100644
--- a/src/Components/ArrayObj.php
+++ b/src/Components/ArrayObj.php
@@ -160,7 +160,7 @@ class ArrayObj extends Component
// (a) => array('a')
//
$lastRaw = trim($lastRaw);
- if ((empty($options['type']))
+ if (empty($options['type'])
&& ((strlen($lastRaw) > 0) || ($isCommaLast))
) {
$ret->raw[] = $lastRaw;
diff --git a/src/Components/DataType.php b/src/Components/DataType.php
index 8218e5b..242947f 100644
--- a/src/Components/DataType.php
+++ b/src/Components/DataType.php
@@ -136,7 +136,7 @@ class DataType extends Component
if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) {
$parameters = ArrayObj::parse($parser, $list);
++$list->idx;
- $ret->parameters = (($ret->name === 'ENUM') || ($ret->name === 'SET')) ?
+ $ret->parameters = ($ret->name === 'ENUM') || ($ret->name === 'SET') ?
$parameters->raw : $parameters->values;
}
$ret->options = OptionsArray::parse($parser, $list, static::$DATA_TYPE_OPTIONS);
diff --git a/src/Components/Key.php b/src/Components/Key.php
index b924c87..92c25ee 100644
--- a/src/Components/Key.php
+++ b/src/Components/Key.php
@@ -161,7 +161,7 @@ class Key extends Component
if ($token->value === '(') {
$state = 3;
} elseif (($token->value === ',') || ($token->value === ')')) {
- $state = ($token->value === ',') ? 2 : 4;
+ $state = $token->value === ',' ? 2 : 4;
if (! empty($lastColumn)) {
$ret->columns[] = $lastColumn;
$lastColumn = [];
diff --git a/src/Components/OptionsArray.php b/src/Components/OptionsArray.php
index ac6d7de..3e8196b 100644
--- a/src/Components/OptionsArray.php
+++ b/src/Components/OptionsArray.php
@@ -288,7 +288,7 @@ class OptionsArray extends Component
$options[] = $option;
} else {
$options[] = $option['name']
- . ((! empty($option['equals']) && $option['equals']) ? '=' : ' ')
+ . (! empty($option['equals']) && $option['equals'] ? '=' : ' ')
. (! empty($option['expr']) ? $option['expr'] : $option['value']);
}
}
diff --git a/src/Components/PartitionDefinition.php b/src/Components/PartitionDefinition.php
index 84322b8..487fffd 100644
--- a/src/Components/PartitionDefinition.php
+++ b/src/Components/PartitionDefinition.php
@@ -247,7 +247,7 @@ class PartitionDefinition extends Component
return trim(
'PARTITION ' . $component->name
. (empty($component->type) ? '' : ' VALUES ' . $component->type . ' ' . $component->expr . ' ')
- . ((! empty($component->options) && ! empty($component->type)) ? '' : ' ') . $component->options . $subpartitions
+ . (! empty($component->options) && ! empty($component->type) ? '' : ' ') . $component->options . $subpartitions
);
}
}
diff --git a/src/Context.php b/src/Context.php
index c9ff19e..98e5177 100644
--- a/src/Context.php
+++ b/src/Context.php
@@ -339,7 +339,7 @@ abstract class Context
if ($str[0] === '#') {
return Token::FLAG_COMMENT_BASH;
} elseif (($len > 1) && ($str[0] === '/') && ($str[1] === '*')) {
- return (($len > 2) && ($str[2] === '!')) ?
+ return ($len > 2) && ($str[2] === '!') ?
Token::FLAG_COMMENT_MYSQL_CMD : Token::FLAG_COMMENT_C;
} elseif (($len > 1) && ($str[0] === '*') && ($str[1] === '/')) {
return Token::FLAG_COMMENT_C;
@@ -385,7 +385,7 @@ abstract class Context
*/
public static function isNumber($str)
{
- return (($str >= '0') && ($str <= '9')) || ($str === '.')
+ return ($str >= '0') && ($str <= '9') || ($str === '.')
|| ($str === '-') || ($str === '+') || ($str === 'e') || ($str === 'E');
}
diff --git a/src/Statement.php b/src/Statement.php
index d2d0ed2..a199219 100644
--- a/src/Statement.php
+++ b/src/Statement.php
@@ -552,7 +552,7 @@ abstract class Statement
$minIdx = $clauseStartIdx;
}
- $lastIdx = ($clauseStartIdx !== -1) ? $clauseStartIdx : $lastIdx;
+ $lastIdx = $clauseStartIdx !== -1 ? $clauseStartIdx : $lastIdx;
}
return true;
diff --git a/src/Statements/CreateStatement.php b/src/Statements/CreateStatement.php
index ffa08bc..da21b42 100644
--- a/src/Statements/CreateStatement.php
+++ b/src/Statements/CreateStatement.php
@@ -622,7 +622,7 @@ class CreateStatement extends Statement
}
// Building the expression used for partitioning.
- $this->$field .= ($token->type === Token::TYPE_WHITESPACE) ? ' ' : $token->token;
+ $this->$field .= $token->type === Token::TYPE_WHITESPACE ? ' ' : $token->token;
// Last bracket was read, the expression ended.
// Comparing with `0` and not `false`, because `false` means
diff --git a/src/Token.php b/src/Token.php
index fe43e8b..f752736 100644
--- a/src/Token.php
+++ b/src/Token.php
@@ -300,7 +300,7 @@ class Token
// in PHP 5.3- the `null` parameter isn't handled correctly.
$str = mb_substr(
$str,
- (! empty($str[1]) && ($str[1] === '@')) ? 2 : 1,
+ ! empty($str[1]) && ($str[1] === '@') ? 2 : 1,
mb_strlen($str),
'UTF-8'
);
diff --git a/src/Utils/Misc.php b/src/Utils/Misc.php
index 9e3ae02..1d12368 100644
--- a/src/Utils/Misc.php
+++ b/src/Utils/Misc.php
@@ -59,7 +59,7 @@ class Misc
continue;
}
- $thisDb = (isset($expr->database) && ($expr->database !== '')) ?
+ $thisDb = isset($expr->database) && ($expr->database !== '') ?
$expr->database : $database;
if (! isset($retval[$thisDb])) {
@@ -71,7 +71,7 @@ class Misc
if (! isset($retval[$thisDb]['tables'][$expr->table])) {
$retval[$thisDb]['tables'][$expr->table] = [
- 'alias' => (isset($expr->alias) && ($expr->alias !== '')) ?
+ 'alias' => isset($expr->alias) && ($expr->alias !== '') ?
$expr->alias : null,
'columns' => [],
];
@@ -89,7 +89,7 @@ class Misc
continue;
}
- $thisDb = (isset($expr->database) && ($expr->database !== '')) ?
+ $thisDb = isset($expr->database) && ($expr->database !== '') ?
$expr->database : $database;
if (isset($expr->table) && ($expr->table !== '')) {
diff --git a/src/Utils/Query.php b/src/Utils/Query.php
index 7b14ded..e22e7f8 100644
--- a/src/Utils/Query.php
+++ b/src/Utils/Query.php
@@ -441,7 +441,7 @@ class Query
} else {
$arr = [
$expr->table,
- (isset($expr->database) && ($expr->database !== '')) ?
+ isset($expr->database) && ($expr->database !== '') ?
$expr->database : null,
];
}
@@ -461,7 +461,7 @@ class Query
if (isset($expr->table) && ($expr->table !== '')) {
$arr = [
$expr->table,
- (isset($expr->database) && ($expr->database !== '')) ?
+ isset($expr->database) && ($expr->database !== '') ?
$expr->database : null,
];
if (! in_array($arr, $ret['select_tables'])) {
diff --git a/tests/Utils/CLITest.php b/tests/Utils/CLITest.php
index 6d0ea4c..da4b2b2 100644
--- a/tests/Utils/CLITest.php
+++ b/tests/Utils/CLITest.php
@@ -174,12 +174,10 @@ class CLITest extends TestCase
public function tokenizeParams()
{
- $result = (
- "[TOKEN 0]\nType = 1\nFlags = 3\nValue = 'SELECT'\nToken = 'SELECT'\n\n"
+ $result = "[TOKEN 0]\nType = 1\nFlags = 3\nValue = 'SELECT'\nToken = 'SELECT'\n\n"
. "[TOKEN 1]\nType = 3\nFlags = 0\nValue = ' '\nToken = ' '\n\n"
. "[TOKEN 2]\nType = 6\nFlags = 0\nValue = 1\nToken = '1'\n\n"
- . "[TOKEN 3]\nType = 9\nFlags = 0\nValue = NULL\nToken = NULL\n\n"
- );
+ . "[TOKEN 3]\nType = 9\nFlags = 0\nValue = NULL\nToken = NULL\n\n";
return [
[
diff --git a/tools/TestGenerator.php b/tools/TestGenerator.php
index abeeb3e..775e097 100644
--- a/tools/TestGenerator.php
+++ b/tools/TestGenerator.php
@@ -41,7 +41,7 @@ class TestGenerator
*
* @var Parser
*/
- $parser = ($type === 'parser') ? new Parser($lexer->list) : null;
+ $parser = $type === 'parser' ? new Parser($lexer->list) : null;
/**
* Lexer's errors.
@@ -158,7 +158,7 @@ class TestGenerator
// Appending the filename to directories.
$inputFile = $input . '/' . $file;
$outputFile = $output . '/' . $file;
- $debugFile = ($debug !== null) ? $debug . '/' . $file : null;
+ $debugFile = $debug !== null ? $debug . '/' . $file : null;
if (is_dir($inputFile)) {
// Creating required directories to maintain the structure.