@@ -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); |
@@ -85,7 +85,7 @@ |
||
| 85 | 85 | $sql = $this->getTwigEnvironment()->render($sql, $parameters); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - $availableParameterKeys = array_keys(array_filter($parameters, static function($param) { return $param !== null;})); |
|
| 88 | + $availableParameterKeys = array_keys(array_filter($parameters, static function($param) { return $param !== null; })); |
|
| 89 | 89 | // We choose md4 because it is fast. |
| 90 | 90 | $cacheKey = 'request_build_'.hash('md4', $sql.'__'.implode('_/_', $availableParameterKeys)); |
| 91 | 91 | $newSql = $this->cache->fetch($cacheKey); |
@@ -168,7 +168,6 @@ |
||
| 168 | 168 | * @param NodeInterface $sqlNode |
| 169 | 169 | * @param array $parameters |
| 170 | 170 | * @param bool $extrapolateParameters Whether the parameters should be fed into the returned SQL query |
| 171 | - |
|
| 172 | 171 | * @return string |
| 173 | 172 | */ |
| 174 | 173 | public function toSql(NodeInterface $sqlNode, array $parameters = array(), bool $extrapolateParameters = true) |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | |
| 34 | 34 | /** @var Twig_Extension_Core $twigExtensionCore */ |
| 35 | 35 | $twigExtensionCore = $twig->getExtension('Twig_Extension_Core'); |
| 36 | - $twigExtensionCore->setEscaper('sql', function () { |
|
| 36 | + $twigExtensionCore->setEscaper('sql', function() { |
|
| 37 | 37 | 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 .... %}"'); |
| 38 | 38 | }); |
| 39 | 39 | |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | |
| 34 | 34 | if ($parameterNode !== null) { |
| 35 | 35 | if (!isset($parameters[$parameterNode->getName()])) { |
| 36 | - throw new MagicQueryException("Missing parameter '" . $parameterNode->getName() . "' for 'IN' operand."); |
|
| 36 | + throw new MagicQueryException("Missing parameter '".$parameterNode->getName()."' for 'IN' operand."); |
|
| 37 | 37 | } |
| 38 | 38 | if ($parameters[$parameterNode->getName()] === []) { |
| 39 | 39 | return "FALSE"; |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Doctrine\DBAL\Platforms\AbstractPlatform; |
| 5 | 5 | use Mouf\Database\MagicQueryException; |
| 6 | -use Mouf\Database\MagicQueryParserException; |
|
| 7 | 6 | use SQLParser\SqlRenderInterface; |
| 8 | 7 | use Mouf\MoufManager; |
| 9 | 8 | use Mouf\MoufInstanceDescriptor; |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | array('NOT'), |
| 507 | 507 | array('&&', 'AND'), |
| 508 | 508 | array('XOR'), |
| 509 | - array('||', 'OR'), ); |
|
| 509 | + array('||', 'OR'),); |
|
| 510 | 510 | |
| 511 | 511 | private static $OPERATOR_TO_CLASS = array( |
| 512 | 512 | '=' => 'SQLParser\Node\Equal', |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | */ |
| 814 | 814 | public static function nodeToInstanceDescriptor($node, MoufManager $moufManager) |
| 815 | 815 | { |
| 816 | - return self::array_map_deep($node, function ($item) use ($moufManager) { |
|
| 816 | + return self::array_map_deep($node, function($item) use ($moufManager) { |
|
| 817 | 817 | if ($item instanceof NodeInterface) { |
| 818 | 818 | return $item->toInstanceDescriptor($moufManager); |
| 819 | 819 | } else { |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | { |
| 858 | 858 | if (is_array($nodes)) { |
| 859 | 859 | $elems = array(); |
| 860 | - array_walk_recursive($nodes, function ($item) use (&$elems, $platform, $indent, $parameters, $conditionsMode, $extrapolateParameters) { |
|
| 860 | + array_walk_recursive($nodes, function($item) use (&$elems, $platform, $indent, $parameters, $conditionsMode, $extrapolateParameters) { |
|
| 861 | 861 | if ($item instanceof SqlRenderInterface) { |
| 862 | 862 | $itemSql = $item->toSql($parameters, $platform, $indent, $conditionsMode, $extrapolateParameters); |
| 863 | 863 | if ($itemSql !== null) { |
@@ -822,6 +822,9 @@ |
||
| 822 | 822 | }); |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | + /** |
|
| 826 | + * @param \Closure $callback |
|
| 827 | + */ |
|
| 825 | 828 | private static function array_map_deep($array, $callback) |
| 826 | 829 | { |
| 827 | 830 | $new = array(); |
@@ -32,7 +32,6 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | namespace SQLParser\Query; |
| 34 | 34 | |
| 35 | -use Doctrine\DBAL\Connection; |
|
| 36 | 35 | use Doctrine\DBAL\Platforms\AbstractPlatform; |
| 37 | 36 | use Mouf\MoufInstanceDescriptor; |
| 38 | 37 | use SQLParser\Node\NodeFactory; |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace SQLParser\Query; |
| 4 | 4 | |
| 5 | -use Doctrine\DBAL\Connection; |
|
| 6 | 5 | use Doctrine\DBAL\Platforms\AbstractPlatform; |
| 7 | 6 | use Mouf\MoufInstanceDescriptor; |
| 8 | 7 | use SQLParser\Node\NodeFactory; |
@@ -166,7 +166,7 @@ |
||
| 166 | 166 | if ($parameters[$this->name] === null) { |
| 167 | 167 | return 'null'; |
| 168 | 168 | } elseif (is_array($parameters[$this->name])) { |
| 169 | - return implode(',', array_map(function ($item) use ($platform) { |
|
| 169 | + return implode(',', array_map(function($item) use ($platform) { |
|
| 170 | 170 | return $platform->quoteStringLiteral($this->autoPrepend.$item.$this->autoAppend); |
| 171 | 171 | }, $parameters[$this->name])); |
| 172 | 172 | } else { |