@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | $this->prefix = $prefix; |
114 | 114 | |
115 | 115 | //Initializing states |
116 | - $this->initial = new TableState($this->prefix . $name); |
|
117 | - $this->current = new TableState($this->prefix . $name); |
|
116 | + $this->initial = new TableState($this->prefix.$name); |
|
117 | + $this->current = new TableState($this->prefix.$name); |
|
118 | 118 | |
119 | 119 | if ($this->driver->hasTable($this->getName())) { |
120 | 120 | $this->status = self::STATUS_EXISTS; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function setName(string $name): string |
195 | 195 | { |
196 | - $this->current->setName($this->prefix . $name); |
|
196 | + $this->current->setName($this->prefix.$name); |
|
197 | 197 | |
198 | 198 | return $this->getName(); |
199 | 199 | } |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | { |
484 | 484 | if ($this->hasIndex($columns)) { |
485 | 485 | throw new SchemaException( |
486 | - "Undefined index ['" . join("', '", $columns) . "'] in '{$this->getName()}'" |
|
486 | + "Undefined index ['".join("', '", $columns)."'] in '{$this->getName()}'" |
|
487 | 487 | ); |
488 | 488 | } |
489 | 489 | |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | { |
528 | 528 | if (empty($schema = $this->current->findIndex($columns))) { |
529 | 529 | throw new SchemaException( |
530 | - "Undefined index ['" . join("', '", $columns) . "'] in '{$this->getName()}'" |
|
530 | + "Undefined index ['".join("', '", $columns)."'] in '{$this->getName()}'" |
|
531 | 531 | ); |
532 | 532 | } |
533 | 533 | |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | */ |
749 | 749 | protected function createIdentifier(string $type, array $columns): string |
750 | 750 | { |
751 | - $name = $this->getName() . '_' . $type . '_' . join('_', $columns) . '_' . uniqid(); |
|
751 | + $name = $this->getName().'_'.$type.'_'.join('_', $columns).'_'.uniqid(); |
|
752 | 752 | |
753 | 753 | if (strlen($name) > 64) { |
754 | 754 | //Many DBMS has limitations on identifier length |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | if (!empty($table->getPrimaryKeys())) { |
270 | 270 | $primaryKeys = array_map([$this, 'quote'], $table->getPrimaryKeys()); |
271 | 271 | |
272 | - $innerStatement[] = 'PRIMARY KEY (' . join(', ', $primaryKeys) . ')'; |
|
272 | + $innerStatement[] = 'PRIMARY KEY ('.join(', ', $primaryKeys).')'; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | //Constraints and foreign keys |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $innerStatement[] = $reference->sqlStatement(); |
278 | 278 | } |
279 | 279 | |
280 | - $statement[] = " " . join(",\n ", $innerStatement); |
|
280 | + $statement[] = " ".join(",\n ", $innerStatement); |
|
281 | 281 | $statement[] = ')'; |
282 | 282 | |
283 | 283 | return join("\n", $statement); |
@@ -228,7 +228,7 @@ |
||
228 | 228 | * Execute statement. |
229 | 229 | * |
230 | 230 | * @param string $statement |
231 | - * @param array $parameters |
|
231 | + * @param string[] $parameters |
|
232 | 232 | * @return \PDOStatement |
233 | 233 | */ |
234 | 234 | protected function run($statement, array $parameters = []) |
@@ -21,10 +21,10 @@ |
||
21 | 21 | $statement = []; |
22 | 22 | |
23 | 23 | $statement[] = 'FOREIGN KEY'; |
24 | - $statement[] = '(' . $driver->identifier($this->column) . ')'; |
|
24 | + $statement[] = '('.$driver->identifier($this->column).')'; |
|
25 | 25 | |
26 | - $statement[] = 'REFERENCES ' . $driver->identifier($this->foreignTable); |
|
27 | - $statement[] = '(' . $driver->identifier($this->foreignKey) . ')'; |
|
26 | + $statement[] = 'REFERENCES '.$driver->identifier($this->foreignTable); |
|
27 | + $statement[] = '('.$driver->identifier($this->foreignKey).')'; |
|
28 | 28 | |
29 | 29 | $statement[] = "ON DELETE {$this->deleteRule}"; |
30 | 30 | $statement[] = "ON UPDATE {$this->updateRule}"; |
@@ -83,7 +83,7 @@ |
||
83 | 83 | private function columnSchemas(array $include = []): array |
84 | 84 | { |
85 | 85 | $columns = $this->driver->query( |
86 | - "PRAGMA TABLE_INFO(" . $this->driver->quote($this->getName()) . ")" |
|
86 | + "PRAGMA TABLE_INFO(".$this->driver->quote($this->getName()).")" |
|
87 | 87 | ); |
88 | 88 | |
89 | 89 | $result = []; |
@@ -130,7 +130,7 @@ |
||
130 | 130 | |
131 | 131 | $quoted = $driver->getPDO()->quote($this->name); |
132 | 132 | |
133 | - return "$statement CHECK ({$quoted} IN (" . implode(', ', $enumValues) . '))'; |
|
133 | + return "$statement CHECK ({$quoted} IN (".implode(', ', $enumValues).'))'; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -139,7 +139,7 @@ |
||
139 | 139 | { |
140 | 140 | //Temporary table is required to copy data over |
141 | 141 | $temporary = clone $table; |
142 | - $temporary->setName('spiral_temp_' . $table->getName() . '_' . uniqid()); |
|
142 | + $temporary->setName('spiral_temp_'.$table->getName().'_'.uniqid()); |
|
143 | 143 | |
144 | 144 | //We don't need any index in temporary table |
145 | 145 | foreach ($temporary->getIndexes() as $index) { |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | |
258 | 258 | //Dropping enum constrain before any operation |
259 | 259 | if ($initial->abstractType() == 'enum' && $this->constrained) { |
260 | - $operations[] = 'DROP CONSTRAINT ' . $driver->identifier($this->enumConstraint()); |
|
260 | + $operations[] = 'DROP CONSTRAINT '.$driver->identifier($this->enumConstraint()); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | //Default value set and dropping |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | |
272 | 272 | //Nullable option |
273 | 273 | if ($initial->nullable != $this->nullable) { |
274 | - $operations[] = "ALTER COLUMN {$identifier} " . (!$this->nullable ? 'SET' : 'DROP') . ' NOT NULL'; |
|
274 | + $operations[] = "ALTER COLUMN {$identifier} ".(!$this->nullable ? 'SET' : 'DROP').' NOT NULL'; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | if ($this->abstractType() == 'enum') { |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | $operations[] = "ADD CONSTRAINT {$driver->identifier($this->enumConstraint())} " |
284 | - . "CHECK ({$identifier} IN (" . implode(', ', $enumValues) . '))'; |
|
284 | + . "CHECK ({$identifier} IN (".implode(', ', $enumValues).'))'; |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | return $operations; |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | protected function prepareEnum(Driver $driver): string |
294 | 294 | { |
295 | 295 | //Postgres enums are just constrained strings |
296 | - return '(' . $this->size . ')'; |
|
296 | + return '('.$this->size.')'; |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | private function enumConstraint(): string |
308 | 308 | { |
309 | 309 | if (empty($this->constrainName)) { |
310 | - $this->constrainName = $this->table . '_' . $this->getName() . '_enum_' . uniqid(); |
|
310 | + $this->constrainName = $this->table.'_'.$this->getName().'_enum_'.uniqid(); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | return $this->constrainName; |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | |
405 | 405 | $constraints = $driver->query($query, [ |
406 | 406 | $tableOID, |
407 | - '(' . $column->name . '%', |
|
408 | - '("' . $column->name . '%' |
|
407 | + '('.$column->name.'%', |
|
408 | + '("'.$column->name.'%' |
|
409 | 409 | ]); |
410 | 410 | |
411 | 411 | foreach ($constraints as $constraint) { |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | */ |
436 | 436 | private static function resolveEnum(Driver $driver, PostgresColumn $column) |
437 | 437 | { |
438 | - $range = $driver->query('SELECT enum_range(NULL::' . $column->type . ')')->fetchColumn(0); |
|
438 | + $range = $driver->query('SELECT enum_range(NULL::'.$column->type.')')->fetchColumn(0); |
|
439 | 439 | |
440 | 440 | $column->enumValues = explode(',', substr($range, 1, -1)); |
441 | 441 |
@@ -106,7 +106,7 @@ |
||
106 | 106 | AbstractColumn $column |
107 | 107 | ) { |
108 | 108 | $this->run("sp_rename ?, ?, 'COLUMN'", [ |
109 | - $table->getName() . '.' . $initial->getName(), |
|
109 | + $table->getName().'.'.$initial->getName(), |
|
110 | 110 | $column->getName() |
111 | 111 | ]); |
112 | 112 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | |
252 | 252 | $type = "ALTER COLUMN {$driver->identifier($this->getName())} varchar($enumSize)"; |
253 | - $operations[] = $type . ' ' . ($this->nullable ? 'NULL' : 'NOT NULL'); |
|
253 | + $operations[] = $type.' '.($this->nullable ? 'NULL' : 'NOT NULL'); |
|
254 | 254 | } else { |
255 | 255 | $type = "ALTER COLUMN {$driver->identifier($this->getName())} {$this->type}"; |
256 | 256 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $type .= "($this->precision, $this->scale)"; |
263 | 263 | } |
264 | 264 | |
265 | - $operations[] = $type . ' ' . ($this->nullable ? 'NULL' : 'NOT NULL'); |
|
265 | + $operations[] = $type.' '.($this->nullable ? 'NULL' : 'NOT NULL'); |
|
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | protected function enumConstraint() |
290 | 290 | { |
291 | 291 | if (empty($this->enumConstraint)) { |
292 | - $this->enumConstraint = $this->table . '_' . $this->getName() . '_enum_' . uniqid(); |
|
292 | + $this->enumConstraint = $this->table.'_'.$this->getName().'_enum_'.uniqid(); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | return $this->enumConstraint; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | protected function defaultConstrain(): string |
304 | 304 | { |
305 | 305 | if (empty($this->defaultConstraint)) { |
306 | - $this->defaultConstraint = $this->table . '_' . $this->getName() . '_default_' . uniqid(); |
|
306 | + $this->defaultConstraint = $this->table.'_'.$this->getName().'_default_'.uniqid(); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | return $this->defaultConstraint; |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | |
437 | 437 | //We made some assumptions here... |
438 | 438 | if (preg_match_all( |
439 | - '/' . $name . '=[\']?([^\']+)[\']?/i', |
|
439 | + '/'.$name.'=[\']?([^\']+)[\']?/i', |
|
440 | 440 | $constraint['definition'], |
441 | 441 | $matches |
442 | 442 | )) { |