@@ -1,8 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Mouf\Database\MagicQuery\Twig; |
| 3 | 3 | |
| 4 | -use Doctrine\DBAL\Connection; |
|
| 5 | - |
|
| 6 | 4 | /** |
| 7 | 5 | * Class in charge of creating the Twig environment |
| 8 | 6 | */ |
@@ -24,7 +24,6 @@ |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * @param string $caller |
|
| 28 | 27 | */ |
| 29 | 28 | public function isOk($parameters = null) |
| 30 | 29 | { |
@@ -635,6 +635,9 @@ discard block |
||
| 635 | 635 | }); |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | + /** |
|
| 639 | + * @param \Closure $callback |
|
| 640 | + */ |
|
| 638 | 641 | private static function array_map_deep($array, $callback) |
| 639 | 642 | { |
| 640 | 643 | $new = array(); |
@@ -661,7 +664,7 @@ discard block |
||
| 661 | 664 | * @param array $parameters |
| 662 | 665 | * @param string $delimiter |
| 663 | 666 | * @param bool|string $wrapInBrackets |
| 664 | - * @param int|number $indent |
|
| 667 | + * @param integer $indent |
|
| 665 | 668 | * @param int $conditionsMode |
| 666 | 669 | * |
| 667 | 670 | * @return null|string |
@@ -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) { |
@@ -181,7 +181,7 @@ |
||
| 181 | 181 | * |
| 182 | 182 | * @param Connection $dbConnection |
| 183 | 183 | * @param array $parameters |
| 184 | - * @param number $indent |
|
| 184 | + * @param integer $indent |
|
| 185 | 185 | * @param int $conditionsMode |
| 186 | 186 | * |
| 187 | 187 | * @return string |
@@ -39,7 +39,6 @@ |
||
| 39 | 39 | use SQLParser\Query\Select; |
| 40 | 40 | use Mouf\MoufInstanceDescriptor; |
| 41 | 41 | use Mouf\MoufManager; |
| 42 | -use SQLParser\SqlRenderInterface; |
|
| 43 | 42 | |
| 44 | 43 | /** |
| 45 | 44 | * This class represents a subquery (and optionally a JOIN .. ON expression in an SQL expression. |
@@ -57,6 +57,9 @@ discard block |
||
| 57 | 57 | $this->allTables = array(); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | + /** |
|
| 61 | + * @param string $txt |
|
| 62 | + */ |
|
| 60 | 63 | public static function dbgprint($txt) |
| 61 | 64 | { |
| 62 | 65 | if (isset($_ENV['DEBUG'])) { |
@@ -95,6 +98,9 @@ discard block |
||
| 95 | 98 | return 'DELETE'; |
| 96 | 99 | } |
| 97 | 100 | |
| 101 | + /** |
|
| 102 | + * @param string $column |
|
| 103 | + */ |
|
| 98 | 104 | public static function getColumnNameFor($column) |
| 99 | 105 | { |
| 100 | 106 | if (strtolower($column) === 'uid') { |
@@ -198,6 +204,10 @@ discard block |
||
| 198 | 204 | return ($res >= 1); |
| 199 | 205 | } |
| 200 | 206 | |
| 207 | + /** |
|
| 208 | + * @param string $table |
|
| 209 | + * @param string $column |
|
| 210 | + */ |
|
| 201 | 211 | protected function isCLOBColumn($table, $column) |
| 202 | 212 | { |
| 203 | 213 | $tables = end($this->allTables); |
@@ -314,6 +324,9 @@ discard block |
||
| 314 | 324 | return 'SELECT '.$sql; |
| 315 | 325 | } |
| 316 | 326 | |
| 327 | + /** |
|
| 328 | + * @param string $sql |
|
| 329 | + */ |
|
| 317 | 330 | private function correctColRefStatement($sql) |
| 318 | 331 | { |
| 319 | 332 | $alias = ''; |
@@ -368,14 +368,14 @@ |
||
| 368 | 368 | { |
| 369 | 369 | $k = key($parsed); |
| 370 | 370 | switch ($k) { |
| 371 | - case 'USE': |
|
| 372 | - # this statement is not an Oracle statement |
|
| 373 | - $this->created = ''; |
|
| 374 | - break; |
|
| 375 | - |
|
| 376 | - default: |
|
| 377 | - $this->created = parent::create($parsed); |
|
| 378 | - break; |
|
| 371 | + case 'USE': |
|
| 372 | + # this statement is not an Oracle statement |
|
| 373 | + $this->created = ''; |
|
| 374 | + break; |
|
| 375 | + |
|
| 376 | + default: |
|
| 377 | + $this->created = parent::create($parsed); |
|
| 378 | + break; |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | return $this->created; |
@@ -237,6 +237,10 @@ |
||
| 237 | 237 | |
| 238 | 238 | # backticks are not balanced within one token, so we have |
| 239 | 239 | # to re-combine some tokens |
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * @param integer $idx |
|
| 243 | + */ |
|
| 240 | 244 | private function balanceCharacter($tokens, $idx, $char) |
| 241 | 245 | { |
| 242 | 246 | $token_count = count($tokens); |
@@ -43,7 +43,6 @@ discard block |
||
| 43 | 43 | /** |
| 44 | 44 | * Prints an array only if debug mode is on. |
| 45 | 45 | * |
| 46 | - * @param array $s |
|
| 47 | 46 | * @param bool $return, if true, the formatted array is returned via return parameter |
| 48 | 47 | */ |
| 49 | 48 | protected function preprint($arr, $return = false) |
@@ -80,6 +79,7 @@ discard block |
||
| 80 | 79 | |
| 81 | 80 | /** |
| 82 | 81 | * Revokes the escaping characters from an expression. |
| 82 | + * @param string $sql |
|
| 83 | 83 | */ |
| 84 | 84 | protected function revokeEscaping($sql) |
| 85 | 85 | { |
@@ -73,6 +73,9 @@ discard block |
||
| 73 | 73 | return $parsed; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | + /** |
|
| 77 | + * @param string $sql |
|
| 78 | + */ |
|
| 76 | 79 | private function findPositionWithinString($sql, $value, $expr_type) |
| 77 | 80 | { |
| 78 | 81 | $offset = 0; |
@@ -130,6 +133,10 @@ discard block |
||
| 130 | 133 | return $pos; |
| 131 | 134 | } |
| 132 | 135 | |
| 136 | + /** |
|
| 137 | + * @param integer $charPos |
|
| 138 | + * @param integer $key |
|
| 139 | + */ |
|
| 133 | 140 | private function lookForBaseExpression($sql, &$charPos, &$parsed, $key, &$backtracking) |
| 134 | 141 | { |
| 135 | 142 | if (!is_numeric($key)) { |
@@ -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 | { |
@@ -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 | { |
@@ -277,7 +277,7 @@ |
||
| 277 | 277 | * |
| 278 | 278 | * @param Connection $dbConnection |
| 279 | 279 | * @param array $parameters |
| 280 | - * @param number $indent |
|
| 280 | + * @param integer $indent |
|
| 281 | 281 | * @param int $conditionsMode |
| 282 | 282 | * |
| 283 | 283 | * @return string |
@@ -360,7 +360,7 @@ |
||
| 360 | 360 | if ($children) { |
| 361 | 361 | if (is_array($children)) { |
| 362 | 362 | foreach ($children as $key => $operand) { |
| 363 | - if($operand) { |
|
| 363 | + if ($operand) { |
|
| 364 | 364 | $result2 = $operand->walk($visitor); |
| 365 | 365 | if ($result2 === NodeTraverser::REMOVE_NODE) { |
| 366 | 366 | unset($children[$key]); |