@@ -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) { |
@@ -33,7 +33,6 @@ |
||
| 33 | 33 | namespace SQLParser\Node; |
| 34 | 34 | |
| 35 | 35 | use Mouf\Database\MagicQueryException; |
| 36 | -use Mouf\Database\MagicQueryParserException; |
|
| 37 | 36 | use SQLParser\SqlRenderInterface; |
| 38 | 37 | use Doctrine\DBAL\Connection; |
| 39 | 38 | use Mouf\MoufManager; |
@@ -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 | { |
@@ -48,7 +48,7 @@ |
||
| 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); |
@@ -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) |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | || $this->isFunction($prev) || $this->isExpression($prev) || $this->isSubQuery($prev) |
| 844 | 844 | || $this->isColumnReference($prev) || $this->isBracketExpression($prev)) { |
| 845 | 845 | $alias = array('as' => false, 'name' => trim($last['base_expr']), |
| 846 | - 'base_expr' => trim($last['base_expr']), ); |
|
| 846 | + 'base_expr' => trim($last['base_expr']),); |
|
| 847 | 847 | #remove the last token |
| 848 | 848 | array_pop($tokens); |
| 849 | 849 | $base_expr = implode('', $tokens); |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | } |
| 874 | 874 | |
| 875 | 875 | return array('expr_type' => $type, 'alias' => $alias, 'base_expr' => trim($base_expr), |
| 876 | - 'sub_tree' => $processed, ); |
|
| 876 | + 'sub_tree' => $processed,); |
|
| 877 | 877 | } |
| 878 | 878 | |
| 879 | 879 | /** |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | return array('expression' => '', 'token_count' => 0, 'table' => '', 'alias' => false, 'join_type' => '', |
| 1016 | 1016 | 'next_join_type' => '', 'saved_join_type' => $parseInfo['saved_join_type'], |
| 1017 | 1017 | 'ref_type' => false, 'ref_expr' => false, 'base_expr' => false, 'sub_tree' => false, |
| 1018 | - 'subquery' => '', ); |
|
| 1018 | + 'subquery' => '',); |
|
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | 1021 | private function processFromExpression(&$parseInfo) |
@@ -1099,7 +1099,7 @@ discard block |
||
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | 1101 | return array('expr_type' => $parseInfo['type'], 'base_expr' => $parseInfo['expr'], |
| 1102 | - 'direction' => $parseInfo['dir'], ); |
|
| 1102 | + 'direction' => $parseInfo['dir'],); |
|
| 1103 | 1103 | } |
| 1104 | 1104 | |
| 1105 | 1105 | private function initParseInfoForOrder() |
@@ -1559,7 +1559,7 @@ discard block |
||
| 1559 | 1559 | unset($values[$k]); |
| 1560 | 1560 | } else { |
| 1561 | 1561 | $values[$k] = array('expr_type' => ExpressionType::RECORD, 'base_expr' => $v, |
| 1562 | - 'data' => $this->process_record($v), ); |
|
| 1562 | + 'data' => $this->process_record($v),); |
|
| 1563 | 1563 | } |
| 1564 | 1564 | } |
| 1565 | 1565 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | if (isset($parameters[$this->name])) { |
| 165 | 165 | if ($dbConnection) { |
| 166 | 166 | if (is_array($parameters[$this->name])) { |
| 167 | - return '('.implode(',', array_map(function ($item) use ($dbConnection) { |
|
| 167 | + return '('.implode(',', array_map(function($item) use ($dbConnection) { |
|
| 168 | 168 | return $dbConnection->quote($this->autoPrepend.$item.$this->autoAppend); |
| 169 | 169 | }, $parameters[$this->name])).')'; |
| 170 | 170 | } else { |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | return 'null'; |
| 176 | 176 | } else { |
| 177 | 177 | if (is_array($parameters[$this->name])) { |
| 178 | - return '('.implode(',', array_map(function ($item) { |
|
| 178 | + return '('.implode(',', array_map(function($item) { |
|
| 179 | 179 | return "'".addslashes($this->autoPrepend.$item.$this->autoAppend)."'"; |
| 180 | 180 | }, $parameters[$this->name])).')'; |
| 181 | 181 | } else { |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | |
| 28 | 28 | // Default escaper will throw an exception. This is because we want to use SQL parameters instead of Twig. |
| 29 | 29 | // This ahs a number of advantages, especially in terms of caching. |
| 30 | - $twig->getExtension('core')->setEscaper('sql', function () { |
|
| 30 | + $twig->getExtension('core')->setEscaper('sql', function() { |
|
| 31 | 31 | throw new ForbiddenTwigParameterInSqlException('You cannot use Twig expressions (like "{{ id }}"). Instead, you should use SQL parameters (like ":id"). Twig integration is limited to Twig statements (like "{% for .... %}"'); |
| 32 | 32 | }); |
| 33 | 33 | |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | $rightOperand = $this->getRightOperand(); |
| 27 | 27 | if ($rightOperand instanceof Parameter) { |
| 28 | 28 | if (!isset($parameters[$rightOperand->getName()])) { |
| 29 | - throw new MagicQueryException("Missing parameter '" . $rightOperand->getName() . "' for 'IN' operand."); |
|
| 29 | + throw new MagicQueryException("Missing parameter '".$rightOperand->getName()."' for 'IN' operand."); |
|
| 30 | 30 | } |
| 31 | 31 | if ($parameters[$rightOperand->getName()] === []) { |
| 32 | 32 | return "FALSE"; |