@@ -37,7 +37,7 @@ |
||
37 | 37 | class LexerSplitter |
38 | 38 | { |
39 | 39 | private static $splitters = array("\r\n", '!=', '>=', '<=', '<>', ':=', '\\', '&&', '>', '<', '|', '=', '^', '(', |
40 | - ')', "\t", "\n", "'", '"', '`', ',', '@', ' ', '+', '-', '*', '/', ';', ); |
|
40 | + ')', "\t", "\n", "'", '"', '`', ',', '@', ' ', '+', '-', '*', '/', ';',); |
|
41 | 41 | private $tokenSize; |
42 | 42 | private $hashSet; |
43 | 43 |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | if (!empty($subTree) && !isset($subTree[0])) { |
336 | 336 | $subTree = StatementFactory::toObject($subTree); |
337 | 337 | } else { |
338 | - $subTree = array_map(function ($item) { |
|
338 | + $subTree = array_map(function($item) { |
|
339 | 339 | if (is_array($item)) { |
340 | 340 | return self::toObject($item); |
341 | 341 | } else { |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | array('NOT'), |
366 | 366 | array('&&', 'AND'), |
367 | 367 | array('XOR'), |
368 | - array('||', 'OR'), ); |
|
368 | + array('||', 'OR'),); |
|
369 | 369 | |
370 | 370 | private static $OPERATOR_TO_CLASS = array( |
371 | 371 | '=' => 'SQLParser\Node\Equal', |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | { |
627 | 627 | $instanceDescriptor = $moufManager->createInstance(get_called_class()); |
628 | 628 | |
629 | - return self::array_map_deep($node, function ($item) use ($moufManager) { |
|
629 | + return self::array_map_deep($node, function($item) use ($moufManager) { |
|
630 | 630 | if ($item instanceof NodeInterface) { |
631 | 631 | return $item->toInstanceDescriptor($moufManager); |
632 | 632 | } else { |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | { |
671 | 671 | if (is_array($nodes)) { |
672 | 672 | $elems = array(); |
673 | - array_walk_recursive($nodes, function ($item) use (&$elems, $dbConnection, $indent, $delimiter, $parameters, $conditionsMode) { |
|
673 | + array_walk_recursive($nodes, function($item) use (&$elems, $dbConnection, $indent, $delimiter, $parameters, $conditionsMode) { |
|
674 | 674 | if ($item instanceof SqlRenderInterface) { |
675 | 675 | $itemSql = $item->toSql($parameters, $dbConnection, $indent, $conditionsMode); |
676 | 676 | if ($itemSql !== null) { |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function setName($name) |
70 | 70 | { |
71 | - if (strrpos($name, '!') === strlen($name)-1) { |
|
72 | - $this->name = substr($name, 0, strlen($name)-1); |
|
71 | + if (strrpos($name, '!') === strlen($name) - 1) { |
|
72 | + $this->name = substr($name, 0, strlen($name) - 1); |
|
73 | 73 | $this->discardedOnNull = false; |
74 | 74 | } else { |
75 | 75 | $this->name = $name; |
@@ -164,22 +164,22 @@ discard block |
||
164 | 164 | { |
165 | 165 | if (isset($parameters[$this->name])) { |
166 | 166 | if ($dbConnection) { |
167 | - if(is_array($parameters[$this->name])){ |
|
168 | - return '('.implode(',',array_map(function($item) use ($dbConnection) { |
|
167 | + if (is_array($parameters[$this->name])) { |
|
168 | + return '('.implode(',', array_map(function($item) use ($dbConnection) { |
|
169 | 169 | return $dbConnection->quote($this->autoPrepend.$item.$this->autoAppend); |
170 | 170 | }, $parameters[$this->name])).')'; |
171 | - } else{ |
|
171 | + } else { |
|
172 | 172 | return $dbConnection->quote($this->autoPrepend.$parameters[$this->name].$this->autoAppend); |
173 | 173 | } |
174 | 174 | } else { |
175 | 175 | if ($parameters[$this->name] === null) { |
176 | 176 | return "null"; |
177 | 177 | } else { |
178 | - if(is_array($parameters[$this->name])){ |
|
179 | - return '('.implode(',',array_map(function($item) { |
|
178 | + if (is_array($parameters[$this->name])) { |
|
179 | + return '('.implode(',', array_map(function($item) { |
|
180 | 180 | return "'".addslashes($this->autoPrepend.$item.$this->autoAppend)."'"; |
181 | 181 | }, $parameters[$this->name])).')'; |
182 | - } else{ |
|
182 | + } else { |
|
183 | 183 | return "'".addslashes($this->autoPrepend.$parameters[$this->name].$this->autoAppend)."'"; |
184 | 184 | } |
185 | 185 |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | 'TRAILING', 'TRUE', 'UNDO', 'UNION', 'UNIQUE', 'UNLOCK', 'UNSIGNED', 'UPDATE', |
99 | 99 | 'USAGE', 'USE', 'USER_RESOURCES', 'USING', 'UTC_DATE', 'UTC_TIME', |
100 | 100 | 'UTC_TIMESTAMP', 'VALUES', 'VARBINARY', 'VARCHAR', 'VARCHARACTER', 'VARYING', |
101 | - 'WHEN', 'WHERE', 'WHILE', 'WITH', 'WRITE', 'XOR', 'YEAR_MONTH', 'ZEROFILL', ); |
|
101 | + 'WHEN', 'WHERE', 'WHILE', 'WITH', 'WRITE', 'XOR', 'YEAR_MONTH', 'ZEROFILL',); |
|
102 | 102 | |
103 | 103 | protected static $parameterizedFunctions = array('ABS', 'ACOS', 'ADDDATE', 'ADDTIME', 'AES_ENCRYPT', 'AES_DECRYPT', |
104 | 104 | 'AGAINST', 'ASCII', 'ASIN', 'ATAN', 'AVG', 'BENCHMARK', 'BIN', |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | 'TIME_TO_SEC', 'TO_DAYS', 'TRIM', 'TRUNCATE', 'UCASE', |
132 | 132 | 'UNCOMPRESS', 'UNCOMPRESSED_LENGTH', 'UNHEX', 'UPPER', 'VAR_POP', |
133 | 133 | 'VAR_SAMP', 'VARIANCE', 'WEEK', 'WEEKDAY', 'WEEKOFYEAR', 'YEAR', |
134 | - 'YEARWEEK', ); |
|
134 | + 'YEARWEEK',); |
|
135 | 135 | |
136 | 136 | protected static $functions = array('ABS', 'ACOS', 'ADDDATE', 'ADDTIME', 'AES_ENCRYPT', 'AES_DECRYPT', 'AGAINST', |
137 | 137 | 'ASCII', 'ASIN', 'ATAN', 'AVG', 'BENCHMARK', 'BIN', 'BIT_AND', 'BIT_OR', |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | 'TIME_TO_SEC', 'TO_DAYS', 'TRIM', 'TRUNCATE', 'UCASE', 'UNCOMPRESS', |
163 | 163 | 'UNCOMPRESSED_LENGTH', 'UNHEX', 'UNIX_TIMESTAMP', 'UPPER', 'USER', 'UTC_DATE', |
164 | 164 | 'UTC_TIME', 'UTC_TIMESTAMP', 'UUID', 'VAR_POP', 'VAR_SAMP', 'VARIANCE', |
165 | - 'VERSION', 'WEEK', 'WEEKDAY', 'WEEKOFYEAR', 'YEAR', 'YEARWEEK', ); |
|
165 | + 'VERSION', 'WEEK', 'WEEKDAY', 'WEEKOFYEAR', 'YEAR', 'YEARWEEK',); |
|
166 | 166 | |
167 | 167 | protected static $aggregateFunctions = array('AVG', 'SUM', 'COUNT', 'MIN', 'MAX', 'STDDEV', 'STDDEV_SAMP', |
168 | 168 | 'STDDEV_POP', 'VARIANCE', 'VAR_SAMP', 'VAR_POP', 'GROUP_CONCAT', |
169 | - 'BIT_AND', 'BIT_OR', 'BIT_XOR', ); |
|
169 | + 'BIT_AND', 'BIT_OR', 'BIT_XOR',); |
|
170 | 170 | } |
@@ -44,7 +44,7 @@ |
||
44 | 44 | { |
45 | 45 | private static $allowedOnOperator = array("\t", "\n", "\r", ' ', ',', '(', ')', '_', "'", '"'); |
46 | 46 | private static $allowedOnOther = array("\t", "\n", "\r", ' ', ',', '(', ')', '<', '>', '*', '+', '-', '/', '|', |
47 | - '&', '=', '!', ';', ); |
|
47 | + '&', '=', '!', ';',); |
|
48 | 48 | |
49 | 49 | private function printPos($text, $sql, $charPos, $key, $parsed, $backtracking) |
50 | 50 | { |
@@ -91,11 +91,11 @@ |
||
91 | 91 | */ |
92 | 92 | public function toSql(array $parameters = array(), Connection $dbConnection = null, $indent = 0, $conditionsMode = self::CONDITION_APPLY) |
93 | 93 | { |
94 | - if($this->value === null) { |
|
94 | + if ($this->value === null) { |
|
95 | 95 | throw new \Exception('A limit parameter must be an integer'); |
96 | 96 | } |
97 | 97 | |
98 | - if(is_numeric($this->value)) { |
|
98 | + if (is_numeric($this->value)) { |
|
99 | 99 | return (int) $this->value; |
100 | 100 | } else if ($dbConnection != null) { |
101 | 101 | return $dbConnection->quote($this->value); |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | $assignment = $this->process_expr_list($this->splitSQLIntoTokens($base_expr)); |
572 | 572 | |
573 | 573 | return array('expr_type' => ExpressionType::EXPRESSION, 'base_expr' => trim($base_expr), |
574 | - 'sub_tree' => $assignment, ); |
|
574 | + 'sub_tree' => $assignment,); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | private function getVariableType($expression) |
@@ -692,8 +692,8 @@ discard block |
||
692 | 692 | } |
693 | 693 | |
694 | 694 | return [ |
695 | - ['expr_type' => 'limit_const', 'base_expr' => trim($offset), 'sub_tree' => false ], |
|
696 | - ['expr_type' => 'limit_const', 'base_expr' => trim($rowcount), 'sub_tree' => false ] |
|
695 | + ['expr_type' => 'limit_const', 'base_expr' => trim($offset), 'sub_tree' => false], |
|
696 | + ['expr_type' => 'limit_const', 'base_expr' => trim($rowcount), 'sub_tree' => false] |
|
697 | 697 | ]; |
698 | 698 | } |
699 | 699 | |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | || $this->isFunction($prev) || $this->isExpression($prev) || $this->isSubQuery($prev) |
847 | 847 | || $this->isColumnReference($prev) || $this->isBracketExpression($prev)) { |
848 | 848 | $alias = array('as' => false, 'name' => trim($last['base_expr']), |
849 | - 'base_expr' => trim($last['base_expr']), ); |
|
849 | + 'base_expr' => trim($last['base_expr']),); |
|
850 | 850 | #remove the last token |
851 | 851 | array_pop($tokens); |
852 | 852 | $base_expr = implode('', $tokens); |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | } |
877 | 877 | |
878 | 878 | return array('expr_type' => $type, 'alias' => $alias, 'base_expr' => trim($base_expr), |
879 | - 'sub_tree' => $processed, ); |
|
879 | + 'sub_tree' => $processed,); |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | /** |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | return array('expression' => '', 'token_count' => 0, 'table' => '', 'alias' => false, 'join_type' => '', |
1019 | 1019 | 'next_join_type' => '', 'saved_join_type' => $parseInfo['saved_join_type'], |
1020 | 1020 | 'ref_type' => false, 'ref_expr' => false, 'base_expr' => false, 'sub_tree' => false, |
1021 | - 'subquery' => '', ); |
|
1021 | + 'subquery' => '',); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | private function processFromExpression(&$parseInfo) |
@@ -1102,7 +1102,7 @@ discard block |
||
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | return array('expr_type' => $parseInfo['type'], 'base_expr' => $parseInfo['expr'], |
1105 | - 'direction' => $parseInfo['dir'], ); |
|
1105 | + 'direction' => $parseInfo['dir'],); |
|
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | private function initParseInfoForOrder() |
@@ -1562,7 +1562,7 @@ discard block |
||
1562 | 1562 | unset($values[$k]); |
1563 | 1563 | } else { |
1564 | 1564 | $values[$k] = array('expr_type' => ExpressionType::RECORD, 'base_expr' => $v, |
1565 | - 'data' => $this->process_record($v), ); |
|
1565 | + 'data' => $this->process_record($v),); |
|
1566 | 1566 | } |
1567 | 1567 | } |
1568 | 1568 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | if (isset($desc['SELECT'])) { |
49 | 49 | $select = new Select(); |
50 | 50 | |
51 | - $columns = array_map(function ($item) { |
|
51 | + $columns = array_map(function($item) { |
|
52 | 52 | return NodeFactory::toObject($item); |
53 | 53 | }, $desc['SELECT']); |
54 | 54 | $columns = NodeFactory::simplify($columns); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @throws \Exception |
119 | 119 | */ |
120 | 120 | private static function checkLimitDesc(array $descLimit) { |
121 | - if(count($descLimit) > 2) { |
|
121 | + if (count($descLimit) > 2) { |
|
122 | 122 | throw new \Exception('The limit returned by the SQLParser contains more than 2 items, something might went wrong.'); |
123 | 123 | } |
124 | 124 | return ['offset' => $descLimit[0], 'limit' => $descLimit[1]]; |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | throw new \Exception('There is no offset if no limit is provided. An error may have occurred during SQLParsing.'); |
389 | 389 | } |
390 | 390 | |
391 | - if($limit !== null) { |
|
391 | + if ($limit !== null) { |
|
392 | 392 | $sql .= "\nLIMIT "; |
393 | 393 | if ($offset !== null) { |
394 | 394 | $sql .= $offset.', '; |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | if ($children) { |
427 | 427 | if (is_array($children)) { |
428 | 428 | foreach ($children as $key => $operand) { |
429 | - if($operand) { |
|
429 | + if ($operand) { |
|
430 | 430 | $result2 = $operand->walk($visitor); |
431 | 431 | if ($result2 === NodeTraverser::REMOVE_NODE) { |
432 | 432 | unset($children[$key]); |