summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Čihař <michal@cihar.com>2017-02-20 13:17:54 +0100
committerMichal Čihař <michal@cihar.com>2017-02-20 13:17:54 +0100
commit273d957f2c82fb9f3726cc62bf515c9a7cd889b6 (patch)
tree53a5b2ff2d4ba3987bc295558b15373cd33e87b5
parent21d143b10673798ff09fc1f31e745cc1931a6819 (diff)
downloadsql-parser-273d957f2c82fb9f3726cc62bf515c9a7cd889b6.zip
sql-parser-273d957f2c82fb9f3726cc62bf515c9a7cd889b6.tar.gz
sql-parser-273d957f2c82fb9f3726cc62bf515c9a7cd889b6.tar.bz2
Aplly coding style fixes
Signed-off-by: Michal Čihař <michal@cihar.com>
-rw-r--r--src/Statement.php6
-rw-r--r--src/Statements/LoadStatement.php43
-rw-r--r--tests/Builder/LoadStatementTest.php5
-rw-r--r--tests/Parser/LoadStatementTest.php2
4 files changed, 25 insertions, 31 deletions
diff --git a/src/Statement.php b/src/Statement.php
index 50b1285..02b8d0b 100644
--- a/src/Statement.php
+++ b/src/Statement.php
@@ -452,7 +452,7 @@ abstract class Statement
/**
* For tracking JOIN clauses in a query
* = 0 - JOIN not found till now
- * > 0 - Index of first JOIN clause in the statement
+ * > 0 - Index of first JOIN clause in the statement.
*
* @var int
*/
@@ -463,7 +463,7 @@ abstract class Statement
* = 0 - JOIN not found till now
* > 0 - Index of last JOIN clause
* (which appears together with other JOINs)
- * in the statement
+ * in the statement.
*
* @var int
*/
@@ -483,7 +483,7 @@ abstract class Statement
if ($minJoin === 0 && stripos($clauseType, 'JOIN')) {
// First JOIN clause is detected
$minJoin = $maxJoin = $clauseStartIdx;
- } elseif ($minJoin !== 0 && ! stripos($clauseType, 'JOIN')) {
+ } elseif ($minJoin !== 0 && !stripos($clauseType, 'JOIN')) {
// After a previous JOIN clause, a non-JOIN clause has been detected
$maxJoin = $lastIdx;
} elseif ($maxJoin < $clauseStartIdx && stripos($clauseType, 'JOIN')) {
diff --git a/src/Statements/LoadStatement.php b/src/Statements/LoadStatement.php
index 55d954b..872f632 100644
--- a/src/Statements/LoadStatement.php
+++ b/src/Statements/LoadStatement.php
@@ -7,14 +7,8 @@
namespace PhpMyAdmin\SqlParser\Statements;
use PhpMyAdmin\SqlParser\Components\ArrayObj;
-use PhpMyAdmin\SqlParser\Components\Condition;
use PhpMyAdmin\SqlParser\Components\Expression;
use PhpMyAdmin\SqlParser\Components\ExpressionArray;
-use PhpMyAdmin\SqlParser\Components\FunctionCall;
-use PhpMyAdmin\SqlParser\Components\IntoKeyword;
-use PhpMyAdmin\SqlParser\Components\JoinKeyword;
-use PhpMyAdmin\SqlParser\Components\Limit;
-use PhpMyAdmin\SqlParser\Components\OrderKeyword;
use PhpMyAdmin\SqlParser\Components\OptionsArray;
use PhpMyAdmin\SqlParser\Components\SetOperation;
use PhpMyAdmin\SqlParser\Parser;
@@ -58,7 +52,7 @@ class LoadStatement extends Statement
public static $OPTIONS = array(
'LOW_PRIORITY' => 1,
'CONCURRENT' => 1,
- 'LOCAL' => 2
+ 'LOCAL' => 2,
);
/**
@@ -84,7 +78,7 @@ class LoadStatement extends Statement
);
/**
- * File name being used to load data
+ * File name being used to load data.
*
* @var Expression
*/
@@ -137,35 +131,35 @@ class LoadStatement extends Statement
public $lines_options;
/**
- * Column names or user variables
+ * Column names or user variables.
*
* @var ExpressionArray
*/
public $col_name_or_user_var;
/**
- * SET clause's updated values(optional)
+ * SET clause's updated values(optional).
*
* @var SetOperation[]
*/
public $set;
/**
- * Ignore 'number' LINES/ROWS
+ * Ignore 'number' LINES/ROWS.
*
* @var Expression
*/
public $ignore_number;
/**
- * REPLACE/IGNORE Keyword
+ * REPLACE/IGNORE Keyword.
*
* @var string
*/
public $replace_ignore;
/**
- * LINES/ROWS Keyword
+ * LINES/ROWS Keyword.
*
* @var string
*/
@@ -232,7 +226,7 @@ class LoadStatement extends Statement
);
++$list->idx;
- /**
+ /**
* The state of the parser.
*
* @var int
@@ -290,7 +284,7 @@ class LoadStatement extends Statement
if ($token->type === Token::TYPE_KEYWORD
&& $token->keyword === 'TABLE'
) {
- $list->idx++;
+ ++$list->idx;
$this->table = Expression::parse($parser, $list, array('parseField' => 'table'));
$state = 3;
} else {
@@ -345,23 +339,25 @@ class LoadStatement extends Statement
}
}
-
- public function parseKeywordsAccordingToState($parser, $list, $state) {
+ public function parseKeywordsAccordingToState($parser, $list, $state)
+ {
$token = $list->tokens[$list->idx];
switch ($state) {
case 3:
if ($token->keyword === 'PARTITION') {
- $list->idx++;
+ ++$list->idx;
$this->partition = ArrayObj::parse($parser, $list);
$state = 4;
+
return $state;
}
case 4:
if ($token->keyword === 'CHARACTER SET') {
- $list->idx++;
+ ++$list->idx;
$this->charset_name = Expression::parse($parser, $list);
$state = 5;
+
return $state;
}
case 5:
@@ -371,11 +367,12 @@ class LoadStatement extends Statement
) {
$this->parseFileOptions($parser, $list, $token->value);
$state = 6;
+
return $state;
}
case 6:
if ($token->keyword === 'IGNORE') {
- $list->idx++;
+ ++$list->idx;
$this->ignore_number = Expression::parse($parser, $list);
$nextToken = $list->getNextOfType(Token::TYPE_KEYWORD);
@@ -387,18 +384,20 @@ class LoadStatement extends Statement
$this->lines_rows = $nextToken->token;
}
$state = 7;
+
return $state;
}
case 7:
if ($token->keyword === 'SET') {
- $list->idx++;
+ ++$list->idx;
$this->set = SetOperation::parse($parser, $list);
$state = 8;
+
return $state;
}
default:
}
+
return $state;
}
-
}
diff --git a/tests/Builder/LoadStatementTest.php b/tests/Builder/LoadStatementTest.php
index 2ef6236..4c4e9b1 100644
--- a/tests/Builder/LoadStatementTest.php
+++ b/tests/Builder/LoadStatementTest.php
@@ -37,7 +37,6 @@ class LoadStatementTest extends TestCase
$stmt->build()
);
-
/* Assertion 3 */
$query = 'LOAD DATA INFILE \'employee3.txt\' '
. 'INTO TABLE employee FIELDS TERMINATED BY '
@@ -53,7 +52,6 @@ class LoadStatementTest extends TestCase
$stmt->build()
);
-
/* Assertion 4 */
$query = 'LOAD DATA INFILE \'/tmp/test.txt\' IGNORE '
. 'INTO TABLE test '
@@ -75,7 +73,6 @@ class LoadStatementTest extends TestCase
$stmt->build()
);
-
/* Assertion 5 */
$query = 'LOAD DATA INFILE \'/tmp/test.txt\' REPLACE '
. 'INTO TABLE test COLUMNS TERMINATED BY \',\' IGNORE 1 ROWS';
@@ -89,7 +86,6 @@ class LoadStatementTest extends TestCase
$stmt->build()
);
-
/* Assertion 6 */
$query = 'LOAD DATA INFILE \'/tmp/test.txt\' IGNORE '
. 'INTO TABLE test PARTITION (p0, p1, p2) CHARACTER SET \'utf8\' '
@@ -107,5 +103,4 @@ class LoadStatementTest extends TestCase
$stmt->build()
);
}
-
}
diff --git a/tests/Parser/LoadStatementTest.php b/tests/Parser/LoadStatementTest.php
index 32b5707..089b1f4 100644
--- a/tests/Parser/LoadStatementTest.php
+++ b/tests/Parser/LoadStatementTest.php
@@ -39,7 +39,7 @@ class LoadStatementTest extends TestCase
array('parser/parseLoadErr3'),
array('parser/parseLoadErr4'),
array('parser/parseLoadErr5'),
- array('parser/parseLoadErr6')
+ array('parser/parseLoadErr6'),
);
}
}