@@ -22,8 +22,8 @@ |
||
22 | 22 | use Doctrine\Common\EventManager; |
23 | 23 | use Doctrine\DBAL\Configuration; |
24 | 24 | use Doctrine\DBAL\Connection; |
25 | -use Doctrine\DBAL\Driver\Connection as DriverConnection; |
|
26 | 25 | use Doctrine\DBAL\Driver; |
26 | +use Doctrine\DBAL\Driver\Connection as DriverConnection; |
|
27 | 27 | use Doctrine\DBAL\Event\ConnectionEventArgs; |
28 | 28 | use Doctrine\DBAL\Events; |
29 | 29 | use Doctrine\DBAL\Sharding\ShardChoser\ShardChoser; |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null) |
95 | 95 | { |
96 | - if (! isset($params['global'], $params['shards'])) { |
|
96 | + if (!isset($params['global'], $params['shards'])) { |
|
97 | 97 | throw new \InvalidArgumentException("Connection Parameters require 'global' and 'shards' configurations."); |
98 | 98 | } |
99 | 99 | |
100 | - if (! isset($params['shardChoser'])) { |
|
100 | + if (!isset($params['shardChoser'])) { |
|
101 | 101 | throw new \InvalidArgumentException("Missing Shard Choser configuration 'shardChoser'"); |
102 | 102 | } |
103 | 103 | |
@@ -105,23 +105,23 @@ discard block |
||
105 | 105 | $params['shardChoser'] = new $params['shardChoser']; |
106 | 106 | } |
107 | 107 | |
108 | - if ( ! ($params['shardChoser'] instanceof ShardChoser)) { |
|
108 | + if (!($params['shardChoser'] instanceof ShardChoser)) { |
|
109 | 109 | throw new \InvalidArgumentException("The 'shardChoser' configuration is not a valid instance of Doctrine\DBAL\Sharding\ShardChoser\ShardChoser"); |
110 | 110 | } |
111 | 111 | |
112 | 112 | $this->connectionParameters[0] = array_merge($params, $params['global']); |
113 | 113 | |
114 | 114 | foreach ($params['shards'] as $shard) { |
115 | - if ( ! isset($shard['id'])) { |
|
115 | + if (!isset($shard['id'])) { |
|
116 | 116 | throw new \InvalidArgumentException("Missing 'id' for one configured shard. Please specify a unique shard-id."); |
117 | 117 | } |
118 | 118 | |
119 | - if ( !is_numeric($shard['id']) || $shard['id'] < 1) { |
|
119 | + if (!is_numeric($shard['id']) || $shard['id'] < 1) { |
|
120 | 120 | throw new \InvalidArgumentException("Shard Id has to be a non-negative number."); |
121 | 121 | } |
122 | 122 | |
123 | 123 | if (isset($this->connectionParameters[$shard['id']])) { |
124 | - throw new \InvalidArgumentException("Shard " . $shard['id'] . " is duplicated in the configuration."); |
|
124 | + throw new \InvalidArgumentException("Shard ".$shard['id']." is duplicated in the configuration."); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | $this->connectionParameters[$shard['id']] = array_merge($params, $shard); |
@@ -32,7 +32,7 @@ |
||
32 | 32 | /** |
33 | 33 | * Picks a shard for the given distribution value. |
34 | 34 | * |
35 | - * @param string|int $distributionValue |
|
35 | + * @param string $distributionValue |
|
36 | 36 | * @param \Doctrine\DBAL\Sharding\PoolingShardConnection $conn |
37 | 37 | * |
38 | 38 | * @return string|int |
@@ -180,7 +180,7 @@ |
||
180 | 180 | /** |
181 | 181 | * @param \Doctrine\DBAL\Schema\Schema $schema |
182 | 182 | * |
183 | - * @return array |
|
183 | + * @return Schema[] |
|
184 | 184 | */ |
185 | 185 | private function partitionSchema(Schema $schema) |
186 | 186 | { |
@@ -19,13 +19,12 @@ |
||
19 | 19 | |
20 | 20 | namespace Doctrine\DBAL\Sharding\SQLAzure; |
21 | 21 | |
22 | -use Doctrine\DBAL\Schema\Schema; |
|
23 | 22 | use Doctrine\DBAL\Connection; |
24 | -use Doctrine\DBAL\Types\Type; |
|
25 | - |
|
23 | +use Doctrine\DBAL\Schema\Schema; |
|
26 | 24 | use Doctrine\DBAL\Schema\Synchronizer\AbstractSchemaSynchronizer; |
27 | -use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer; |
|
28 | 25 | use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer; |
26 | +use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer; |
|
27 | +use Doctrine\DBAL\Types\Type; |
|
29 | 28 | use function array_merge; |
30 | 29 | |
31 | 30 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $globalSql = $this->synchronizer->getCreateSchema($global); |
78 | 78 | if ($globalSql) { |
79 | 79 | $sql[] = "-- Create Root Federation\n" . |
80 | - "USE FEDERATION ROOT WITH RESET;"; |
|
80 | + "USE FEDERATION ROOT WITH RESET;"; |
|
81 | 81 | $sql = array_merge($sql, $globalSql); |
82 | 82 | } |
83 | 83 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $federationSql = $this->synchronizer->getDropAllSchema(); |
159 | 159 | if ($federationSql) { |
160 | 160 | $sql[] = "-- Work on Federation ID " . $shard['id'] . "\n" . |
161 | - "USE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " = " . $shard['rangeLow'].") WITH RESET, FILTERING = OFF;"; |
|
161 | + "USE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " = " . $shard['rangeLow'].") WITH RESET, FILTERING = OFF;"; |
|
162 | 162 | $sql = array_merge($sql, $federationSql); |
163 | 163 | } |
164 | 164 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $federationSql = $operation($this->synchronizer, $federation); |
254 | 254 | if ($federationSql) { |
255 | 255 | $sql[] = "-- Work on Federation ID " . $shard['id'] . "\n" . |
256 | - "USE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " = " . $shard['rangeLow'].") WITH RESET, FILTERING = OFF;"; |
|
256 | + "USE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " = " . $shard['rangeLow'].") WITH RESET, FILTERING = OFF;"; |
|
257 | 257 | $sql = array_merge($sql, $federationSql); |
258 | 258 | } |
259 | 259 | } |
@@ -294,6 +294,6 @@ discard block |
||
294 | 294 | $federationTypeSql = $federationType->getSQLDeclaration([], $this->conn->getDatabasePlatform()); |
295 | 295 | |
296 | 296 | return "--Create Federation\n" . |
297 | - "CREATE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " " . $federationTypeSql ." RANGE)"; |
|
297 | + "CREATE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " " . $federationTypeSql ." RANGE)"; |
|
298 | 298 | } |
299 | 299 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | $globalSql = $this->synchronizer->getCreateSchema($global); |
78 | 78 | if ($globalSql) { |
79 | - $sql[] = "-- Create Root Federation\n" . |
|
79 | + $sql[] = "-- Create Root Federation\n". |
|
80 | 80 | "USE FEDERATION ROOT WITH RESET;"; |
81 | 81 | $sql = array_merge($sql, $globalSql); |
82 | 82 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $defaultValue = $this->getFederationTypeDefaultValue(); |
88 | 88 | |
89 | 89 | $sql[] = $this->getCreateFederationStatement(); |
90 | - $sql[] = "USE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " = " . $defaultValue . ") WITH RESET, FILTERING = OFF;"; |
|
90 | + $sql[] = "USE FEDERATION ".$this->shardManager->getFederationName()." (".$this->shardManager->getDistributionKey()." = ".$defaultValue.") WITH RESET, FILTERING = OFF;"; |
|
91 | 91 | $sql = array_merge($sql, $federationSql); |
92 | 92 | } |
93 | 93 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function getUpdateSchema(Schema $toSchema, $noDrops = false) |
101 | 101 | { |
102 | - return $this->work($toSchema, function ($synchronizer, $schema) use ($noDrops) { |
|
102 | + return $this->work($toSchema, function($synchronizer, $schema) use ($noDrops) { |
|
103 | 103 | return $synchronizer->getUpdateSchema($schema, $noDrops); |
104 | 104 | }); |
105 | 105 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function getDropSchema(Schema $dropSchema) |
111 | 111 | { |
112 | - return $this->work($dropSchema, function ($synchronizer, $schema) { |
|
112 | + return $this->work($dropSchema, function($synchronizer, $schema){ |
|
113 | 113 | return $synchronizer->getDropSchema($schema); |
114 | 114 | }); |
115 | 115 | } |
@@ -157,14 +157,14 @@ discard block |
||
157 | 157 | |
158 | 158 | $federationSql = $this->synchronizer->getDropAllSchema(); |
159 | 159 | if ($federationSql) { |
160 | - $sql[] = "-- Work on Federation ID " . $shard['id'] . "\n" . |
|
161 | - "USE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " = " . $shard['rangeLow'].") WITH RESET, FILTERING = OFF;"; |
|
160 | + $sql[] = "-- Work on Federation ID ".$shard['id']."\n". |
|
161 | + "USE FEDERATION ".$this->shardManager->getFederationName()." (".$this->shardManager->getDistributionKey()." = ".$shard['rangeLow'].") WITH RESET, FILTERING = OFF;"; |
|
162 | 162 | $sql = array_merge($sql, $federationSql); |
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | 166 | $sql[] = "USE FEDERATION ROOT WITH RESET;"; |
167 | - $sql[] = "DROP FEDERATION " . $this->shardManager->getFederationName(); |
|
167 | + $sql[] = "DROP FEDERATION ".$this->shardManager->getFederationName(); |
|
168 | 168 | |
169 | 169 | return $sql; |
170 | 170 | } |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | |
253 | 253 | $federationSql = $operation($this->synchronizer, $federation); |
254 | 254 | if ($federationSql) { |
255 | - $sql[] = "-- Work on Federation ID " . $shard['id'] . "\n" . |
|
256 | - "USE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " = " . $shard['rangeLow'].") WITH RESET, FILTERING = OFF;"; |
|
255 | + $sql[] = "-- Work on Federation ID ".$shard['id']."\n". |
|
256 | + "USE FEDERATION ".$this->shardManager->getFederationName()." (".$this->shardManager->getDistributionKey()." = ".$shard['rangeLow'].") WITH RESET, FILTERING = OFF;"; |
|
257 | 257 | $sql = array_merge($sql, $federationSql); |
258 | 258 | } |
259 | 259 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | $federationType = Type::getType($this->shardManager->getDistributionType()); |
294 | 294 | $federationTypeSql = $federationType->getSQLDeclaration([], $this->conn->getDatabasePlatform()); |
295 | 295 | |
296 | - return "--Create Federation\n" . |
|
297 | - "CREATE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " " . $federationTypeSql ." RANGE)"; |
|
296 | + return "--Create Federation\n". |
|
297 | + "CREATE FEDERATION ".$this->shardManager->getFederationName()." (".$this->shardManager->getDistributionKey()." ".$federationTypeSql." RANGE)"; |
|
298 | 298 | } |
299 | 299 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function getUpdateSchema(Schema $toSchema, $noDrops = false) |
101 | 101 | { |
102 | - return $this->work($toSchema, function ($synchronizer, $schema) use ($noDrops) { |
|
102 | + return $this->work($toSchema, function ($synchronizer, $schema) use ($noDrops){ |
|
103 | 103 | return $synchronizer->getUpdateSchema($schema, $noDrops); |
104 | 104 | }); |
105 | 105 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function getDropSchema(Schema $dropSchema) |
111 | 111 | { |
112 | - return $this->work($dropSchema, function ($synchronizer, $schema) { |
|
112 | + return $this->work($dropSchema, function ($synchronizer, $schema){ |
|
113 | 113 | return $synchronizer->getDropSchema($schema); |
114 | 114 | }); |
115 | 115 | } |
@@ -20,8 +20,8 @@ |
||
20 | 20 | namespace Doctrine\DBAL\Sharding\SQLAzure; |
21 | 21 | |
22 | 22 | use Doctrine\DBAL\Connection; |
23 | -use Doctrine\DBAL\Sharding\ShardingException; |
|
24 | 23 | use Doctrine\DBAL\Sharding\ShardManager; |
24 | +use Doctrine\DBAL\Sharding\ShardingException; |
|
25 | 25 | use Doctrine\DBAL\Types\Type; |
26 | 26 | use function is_bool; |
27 | 27 | use function is_scalar; |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | return $this->conn->fetchAll($sql); |
199 | 199 | } |
200 | 200 | |
201 | - /** |
|
202 | - * {@inheritDoc} |
|
203 | - */ |
|
201 | + /** |
|
202 | + * {@inheritDoc} |
|
203 | + */ |
|
204 | 204 | public function queryAll($sql, array $params = [], array $types = []) |
205 | 205 | { |
206 | 206 | $shards = $this->getShards(); |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | $type = Type::getType($this->distributionType); |
240 | 240 | |
241 | 241 | $sql = "ALTER FEDERATION " . $this->getFederationName() . " " . |
242 | - "SPLIT AT (" . $this->getDistributionKey() . " = " . |
|
243 | - $this->conn->quote($splitDistributionValue, $type->getBindingType()) . ")"; |
|
242 | + "SPLIT AT (" . $this->getDistributionKey() . " = " . |
|
243 | + $this->conn->quote($splitDistributionValue, $type->getBindingType()) . ")"; |
|
244 | 244 | $this->conn->exec($sql); |
245 | 245 | } |
246 | 246 | } |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | $this->conn = $conn; |
75 | 75 | $params = $conn->getParams(); |
76 | 76 | |
77 | - if ( ! isset($params['sharding']['federationName'])) { |
|
77 | + if (!isset($params['sharding']['federationName'])) { |
|
78 | 78 | throw ShardingException::missingDefaultFederationName(); |
79 | 79 | } |
80 | 80 | |
81 | - if ( ! isset($params['sharding']['distributionKey'])) { |
|
81 | + if (!isset($params['sharding']['distributionKey'])) { |
|
82 | 82 | throw ShardingException::missingDefaultDistributionKey(); |
83 | 83 | } |
84 | 84 | |
85 | - if ( ! isset($params['sharding']['distributionType'])) { |
|
85 | + if (!isset($params['sharding']['distributionType'])) { |
|
86 | 86 | throw ShardingException::missingDistributionType(); |
87 | 87 | } |
88 | 88 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | { |
206 | 206 | $shards = $this->getShards(); |
207 | 207 | if (!$shards) { |
208 | - throw new \RuntimeException("No shards found for " . $this->federationName); |
|
208 | + throw new \RuntimeException("No shards found for ".$this->federationName); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | $result = []; |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | { |
239 | 239 | $type = Type::getType($this->distributionType); |
240 | 240 | |
241 | - $sql = "ALTER FEDERATION " . $this->getFederationName() . " " . |
|
242 | - "SPLIT AT (" . $this->getDistributionKey() . " = " . |
|
243 | - $this->conn->quote($splitDistributionValue, $type->getBindingType()) . ")"; |
|
241 | + $sql = "ALTER FEDERATION ".$this->getFederationName()." ". |
|
242 | + "SPLIT AT (".$this->getDistributionKey()." = ". |
|
243 | + $this->conn->quote($splitDistributionValue, $type->getBindingType()).")"; |
|
244 | 244 | $this->conn->exec($sql); |
245 | 245 | } |
246 | 246 | } |
@@ -277,7 +277,7 @@ |
||
277 | 277 | * |
278 | 278 | * @param int $columnIndex |
279 | 279 | * |
280 | - * @return mixed A single column from the next row of a result set or FALSE if there are no more rows. |
|
280 | + * @return string|boolean A single column from the next row of a result set or FALSE if there are no more rows. |
|
281 | 281 | */ |
282 | 282 | public function fetchColumn($columnIndex = 0) |
283 | 283 | { |
@@ -19,8 +19,8 @@ |
||
19 | 19 | |
20 | 20 | namespace Doctrine\DBAL; |
21 | 21 | |
22 | -use Doctrine\DBAL\Types\Type; |
|
23 | 22 | use Doctrine\DBAL\Driver\Statement as DriverStatement; |
23 | +use Doctrine\DBAL\Types\Type; |
|
24 | 24 | use function is_array; |
25 | 25 | use function is_string; |
26 | 26 |
@@ -23,8 +23,8 @@ |
||
23 | 23 | use Symfony\Component\Console\Command\Command; |
24 | 24 | use Symfony\Component\Console\Input\InputArgument; |
25 | 25 | use Symfony\Component\Console\Input\InputInterface; |
26 | -use Symfony\Component\Console\Output\OutputInterface; |
|
27 | 26 | use Symfony\Component\Console\Input\InputOption; |
27 | +use Symfony\Component\Console\Output\OutputInterface; |
|
28 | 28 | use function is_numeric; |
29 | 29 | use function stripos; |
30 | 30 |
@@ -73,7 +73,7 @@ |
||
73 | 73 | |
74 | 74 | $depth = $input->getOption('depth'); |
75 | 75 | |
76 | - if ( ! is_numeric($depth)) { |
|
76 | + if (!is_numeric($depth)) { |
|
77 | 77 | throw new \LogicException("Option 'depth' must contains an integer value"); |
78 | 78 | } |
79 | 79 |
@@ -56,7 +56,7 @@ |
||
56 | 56 | ]) |
57 | 57 | ->setHelp(<<<EOT |
58 | 58 | Executes arbitrary SQL directly from the command line. |
59 | -EOT |
|
59 | +eot |
|
60 | 60 | ); |
61 | 61 | } |
62 | 62 |
@@ -19,8 +19,8 @@ |
||
19 | 19 | |
20 | 20 | namespace Doctrine\DBAL\Tools\Console\Helper; |
21 | 21 | |
22 | -use Symfony\Component\Console\Helper\Helper; |
|
23 | 22 | use Doctrine\DBAL\Connection; |
23 | +use Symfony\Component\Console\Helper\Helper; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Doctrine CLI Connection Helper. |
@@ -136,7 +136,7 @@ |
||
136 | 136 | * |
137 | 137 | * @param object $var |
138 | 138 | * |
139 | - * @return mixed |
|
139 | + * @return stdClass |
|
140 | 140 | */ |
141 | 141 | private static function fillReturnWithClassAttributes($var, stdClass $return, int $maxDepth) |
142 | 142 | { |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | if ($maxDepth === 0) { |
92 | 92 | return is_object($var) ? get_class($var) |
93 | - : (is_array($var) ? 'Array(' . count($var) . ')' : $var); |
|
93 | + : (is_array($var) ? 'Array('.count($var).')' : $var); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | if (is_array($var)) { |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | return $return; |
104 | 104 | } |
105 | 105 | |
106 | - if (! $isObj) { |
|
106 | + if (!$isObj) { |
|
107 | 107 | return $var; |
108 | 108 | } |
109 | 109 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $aux = explode("\0", $key); |
147 | 147 | $name = end($aux); |
148 | 148 | if ($aux[0] === '') { |
149 | - $name .= ':' . ($aux[1] === '*' ? 'protected' : $aux[1] . ':private'); |
|
149 | + $name .= ':'.($aux[1] === '*' ? 'protected' : $aux[1].':private'); |
|
150 | 150 | } |
151 | 151 | $return->$name = self::export($clone[$key], $maxDepth - 1); |
152 | 152 | } |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | { |
162 | 162 | $class = get_class($object); |
163 | 163 | |
164 | - if (! class_exists(Proxy::class)) { |
|
164 | + if (!class_exists(Proxy::class)) { |
|
165 | 165 | return $class; |
166 | 166 | } |
167 | 167 | |
168 | - $pos = strrpos($class, '\\' . Proxy::MARKER . '\\'); |
|
168 | + $pos = strrpos($class, '\\'.Proxy::MARKER.'\\'); |
|
169 | 169 | |
170 | 170 | if ($pos === false) { |
171 | 171 | return $class; |
@@ -19,9 +19,9 @@ |
||
19 | 19 | |
20 | 20 | namespace Doctrine\DBAL\Types; |
21 | 21 | |
22 | +use Doctrine\DBAL\DBALException; |
|
22 | 23 | use Doctrine\DBAL\ParameterType; |
23 | 24 | use Doctrine\DBAL\Platforms\AbstractPlatform; |
24 | -use Doctrine\DBAL\DBALException; |
|
25 | 25 | use function end; |
26 | 26 | use function explode; |
27 | 27 | use function get_class; |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public static function getType($name) |
186 | 186 | { |
187 | - if ( ! isset(self::$_typeObjects[$name])) { |
|
188 | - if ( ! isset(self::$_typesMap[$name])) { |
|
187 | + if (!isset(self::$_typeObjects[$name])) { |
|
188 | + if (!isset(self::$_typesMap[$name])) { |
|
189 | 189 | throw DBALException::unknownColumnType($name); |
190 | 190 | } |
191 | 191 | self::$_typeObjects[$name] = new self::$_typesMap[$name](); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public static function overrideType($name, $className) |
239 | 239 | { |
240 | - if ( ! isset(self::$_typesMap[$name])) { |
|
240 | + if (!isset(self::$_typesMap[$name])) { |
|
241 | 241 | throw DBALException::typeNotFound($name); |
242 | 242 | } |
243 | 243 |