@@ -25,7 +25,7 @@ |
||
25 | 25 | { |
26 | 26 | $currentDbName = $dbDriver->getScalar( |
27 | 27 | "SELECT datname FROM pg_catalog.pg_database WHERE lower(datname) = lower(:dbname)", |
28 | - ['dbname' => $database] |
|
28 | + [ 'dbname' => $database ] |
|
29 | 29 | ); |
30 | 30 | |
31 | 31 | if (empty($currentDbName)) { |
@@ -63,15 +63,15 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function getVersion() |
65 | 65 | { |
66 | - $result = []; |
|
66 | + $result = [ ]; |
|
67 | 67 | try { |
68 | - $result['version'] = $this->getDbDriver()->getScalar('SELECT version FROM ' . $this->getMigrationTable()); |
|
68 | + $result[ 'version' ] = $this->getDbDriver()->getScalar('SELECT version FROM ' . $this->getMigrationTable()); |
|
69 | 69 | } catch (\Exception $ex) { |
70 | 70 | throw new DatabaseNotVersionedException('This database does not have a migration version. Please use "migrate reset" or "migrate install" to create one.'); |
71 | 71 | } |
72 | 72 | |
73 | 73 | try { |
74 | - $result['status'] = $this->getDbDriver()->getScalar('SELECT status FROM ' . $this->getMigrationTable()); |
|
74 | + $result[ 'status' ] = $this->getDbDriver()->getScalar('SELECT status FROM ' . $this->getMigrationTable()); |
|
75 | 75 | } catch (\Exception $ex) { |
76 | 76 | throw new OldVersionSchemaException('This database does not have a migration version. Please use "migrate install" for update it.'); |
77 | 77 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | // Get the version to check if exists |
104 | 104 | $versionInfo = $this->getVersion(); |
105 | - if ($versionInfo['version'] === false) { |
|
105 | + if ($versionInfo[ 'version' ] === false) { |
|
106 | 106 | $this->getDbDriver()->execute(sprintf( |
107 | 107 | "insert into %s values(0, '%s')", |
108 | 108 | $this->getMigrationTable(), |
@@ -119,23 +119,23 @@ discard block |
||
119 | 119 | protected function getExpectedUsersVersion0() |
120 | 120 | { |
121 | 121 | return [ |
122 | - ["id" => 1, "name" => 'John Doe', 'createdate' => '20160110'], |
|
123 | - ["id" => 2, "name" => 'Jane Doe', 'createdate' => '20151230'] |
|
122 | + [ "id" => 1, "name" => 'John Doe', 'createdate' => '20160110' ], |
|
123 | + [ "id" => 2, "name" => 'Jane Doe', 'createdate' => '20151230' ] |
|
124 | 124 | ]; |
125 | 125 | } |
126 | 126 | |
127 | 127 | protected function getExpectedUsersVersion1() |
128 | 128 | { |
129 | 129 | return [ |
130 | - ["id" => 1, "name" => 'John Doe', 'createdate' => '2016-01-10'], |
|
131 | - ["id" => 2, "name" => 'Jane Doe', 'createdate' => '2015-12-30'] |
|
130 | + [ "id" => 1, "name" => 'John Doe', 'createdate' => '2016-01-10' ], |
|
131 | + [ "id" => 2, "name" => 'Jane Doe', 'createdate' => '2015-12-30' ] |
|
132 | 132 | ]; |
133 | 133 | } |
134 | 134 | |
135 | 135 | protected function getExpectedPostsVersion2() |
136 | 136 | { |
137 | 137 | return [ |
138 | - ["id" => 1, "userid" => 1, "title" => 'Testing', 'post' => "<!-- wp:paragraph -->\\n<p>This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:</p>\\n<!-- /wp:paragraph -->\\n\\n<!-- wp:quote -->\\n<blockquote class=\"wp-block-quote\"><p>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)</p></blockquote>\\n<!-- /wp:quote -->\\n\\n<!-- wp:paragraph -->\\n<p>...or something like this:</p>\\n<!-- /wp:paragraph -->\\n\\n<!-- wp:quote -->\\n<blockquote class=\"wp-block-quote\"><p>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</p></blockquote>\\n<!-- /wp:quote -->\\n\\n<!-- wp:paragraph -->\\n<p>As a new WordPress user, you should go to <a href=\"http://home.home.lcl/wordpress/wp-admin/\">your dashboard</a> to delete this page and create new pages for your content. Have fun!</p>\\n<!-- /wp:paragraph -->"], |
|
138 | + [ "id" => 1, "userid" => 1, "title" => 'Testing', 'post' => "<!-- wp:paragraph -->\\n<p>This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:</p>\\n<!-- /wp:paragraph -->\\n\\n<!-- wp:quote -->\\n<blockquote class=\"wp-block-quote\"><p>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)</p></blockquote>\\n<!-- /wp:quote -->\\n\\n<!-- wp:paragraph -->\\n<p>...or something like this:</p>\\n<!-- /wp:paragraph -->\\n\\n<!-- wp:quote -->\\n<blockquote class=\"wp-block-quote\"><p>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</p></blockquote>\\n<!-- /wp:quote -->\\n\\n<!-- wp:paragraph -->\\n<p>As a new WordPress user, you should go to <a href=\"http://home.home.lcl/wordpress/wp-admin/\">your dashboard</a> to delete this page and create new pages for your content. Have fun!</p>\\n<!-- /wp:paragraph -->" ], |
|
139 | 139 | ]; |
140 | 140 | } |
141 | 141 | |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | */ |
146 | 146 | protected function assertVersion0() |
147 | 147 | { |
148 | - $version = $this->migrate->getDbDriver()->getScalar('select version from '. $this->migrationTable); |
|
148 | + $version = $this->migrate->getDbDriver()->getScalar('select version from ' . $this->migrationTable); |
|
149 | 149 | $this->assertEquals(0, $version); |
150 | - $status = $this->migrate->getDbDriver()->getScalar('select status from '. $this->migrationTable); |
|
150 | + $status = $this->migrate->getDbDriver()->getScalar('select status from ' . $this->migrationTable); |
|
151 | 151 | $this->assertEquals(Migration::VERSION_STATUS_COMPLETE, $status); |
152 | 152 | |
153 | 153 | $iterator = $this->migrate->getDbDriver()->getIterator('select * from users'); |
@@ -155,14 +155,14 @@ discard block |
||
155 | 155 | $this->assertTrue($iterator->hasNext()); |
156 | 156 | $row = $iterator->moveNext(); |
157 | 157 | $this->assertEquals( |
158 | - $this->getExpectedUsersVersion0()[0], |
|
158 | + $this->getExpectedUsersVersion0()[ 0 ], |
|
159 | 159 | $row->toArray() |
160 | 160 | ); |
161 | 161 | |
162 | 162 | $this->assertTrue($iterator->hasNext()); |
163 | 163 | $row = $iterator->moveNext(); |
164 | 164 | $this->assertEquals( |
165 | - $this->getExpectedUsersVersion0()[1], |
|
165 | + $this->getExpectedUsersVersion0()[ 1 ], |
|
166 | 166 | $row->toArray() |
167 | 167 | ); |
168 | 168 | |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | */ |
182 | 182 | protected function assertVersion1() |
183 | 183 | { |
184 | - $version = $this->migrate->getDbDriver()->getScalar('select version from '. $this->migrationTable); |
|
184 | + $version = $this->migrate->getDbDriver()->getScalar('select version from ' . $this->migrationTable); |
|
185 | 185 | $this->assertEquals(1, $version); |
186 | - $status = $this->migrate->getDbDriver()->getScalar('select status from '. $this->migrationTable); |
|
186 | + $status = $this->migrate->getDbDriver()->getScalar('select status from ' . $this->migrationTable); |
|
187 | 187 | $this->assertEquals(Migration::VERSION_STATUS_COMPLETE, $status); |
188 | 188 | |
189 | 189 | $iterator = $this->migrate->getDbDriver()->getIterator('select * from users'); |
@@ -191,14 +191,14 @@ discard block |
||
191 | 191 | $this->assertTrue($iterator->hasNext()); |
192 | 192 | $row = $iterator->moveNext(); |
193 | 193 | $this->assertEquals( |
194 | - $this->getExpectedUsersVersion1()[0], |
|
194 | + $this->getExpectedUsersVersion1()[ 0 ], |
|
195 | 195 | $row->toArray() |
196 | 196 | ); |
197 | 197 | |
198 | 198 | $this->assertTrue($iterator->hasNext()); |
199 | 199 | $row = $iterator->moveNext(); |
200 | 200 | $this->assertEquals( |
201 | - $this->getExpectedUsersVersion1()[1], |
|
201 | + $this->getExpectedUsersVersion1()[ 1 ], |
|
202 | 202 | $row->toArray() |
203 | 203 | ); |
204 | 204 | |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function assertVersion2() |
219 | 219 | { |
220 | - $version = $this->migrate->getDbDriver()->getScalar('select version from '. $this->migrationTable); |
|
220 | + $version = $this->migrate->getDbDriver()->getScalar('select version from ' . $this->migrationTable); |
|
221 | 221 | $this->assertEquals(2, $version); |
222 | - $status = $this->migrate->getDbDriver()->getScalar('select status from '. $this->migrationTable); |
|
222 | + $status = $this->migrate->getDbDriver()->getScalar('select status from ' . $this->migrationTable); |
|
223 | 223 | $this->assertEquals(Migration::VERSION_STATUS_COMPLETE, $status); |
224 | 224 | |
225 | 225 | // Users |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | $this->assertTrue($iterator->hasNext()); |
229 | 229 | $row = $iterator->moveNext(); |
230 | 230 | $this->assertEquals( |
231 | - $this->getExpectedUsersVersion1()[0], |
|
231 | + $this->getExpectedUsersVersion1()[ 0 ], |
|
232 | 232 | $row->toArray() |
233 | 233 | ); |
234 | 234 | |
235 | 235 | $this->assertTrue($iterator->hasNext()); |
236 | 236 | $row = $iterator->moveNext(); |
237 | 237 | $this->assertEquals( |
238 | - $this->getExpectedUsersVersion1()[1], |
|
238 | + $this->getExpectedUsersVersion1()[ 1 ], |
|
239 | 239 | $row->toArray() |
240 | 240 | ); |
241 | 241 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $this->assertTrue($iterator->hasNext()); |
248 | 248 | $row = $iterator->moveNext(); |
249 | 249 | $this->assertEquals( |
250 | - $this->getExpectedPostsVersion2()[0], |
|
250 | + $this->getExpectedPostsVersion2()[ 0 ], |
|
251 | 251 | $row->toArray() |
252 | 252 | ); |
253 | 253 | } |
@@ -43,8 +43,8 @@ |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | return [ |
46 | - ["id" => 1, "name" => 'John Doe', 'createdate' => '2016-01-10 00:00:00'], |
|
47 | - ["id" => 2, "name" => 'Jane Doe', 'createdate' => '2015-12-30 00:00:00'] |
|
46 | + [ "id" => 1, "name" => 'John Doe', 'createdate' => '2016-01-10 00:00:00' ], |
|
47 | + [ "id" => 2, "name" => 'Jane Doe', 'createdate' => '2015-12-30 00:00:00' ] |
|
48 | 48 | ]; |
49 | 49 | } |
50 | 50 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * @var array |
46 | 46 | */ |
47 | - protected static $databases = []; |
|
47 | + protected static $databases = [ ]; |
|
48 | 48 | /** |
49 | 49 | * @var string |
50 | 50 | */ |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | $protocolList = $class::schema(); |
84 | 84 | foreach ((array)$protocolList as $item) { |
85 | - self::$databases[$item] = $class; |
|
85 | + self::$databases[ $item ] = $class; |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | */ |
120 | 120 | protected function getDatabaseClassName() |
121 | 121 | { |
122 | - if (isset(self::$databases[$this->uri->getScheme()])) { |
|
123 | - return self::$databases[$this->uri->getScheme()]; |
|
122 | + if (isset(self::$databases[ $this->uri->getScheme() ])) { |
|
123 | + return self::$databases[ $this->uri->getScheme() ]; |
|
124 | 124 | } |
125 | 125 | throw new DatabaseDoesNotRegistered( |
126 | 126 | 'Scheme "' . $this->uri->getScheme() . '" does not found. Did you registered it?' |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | . "/" . ($increment < 0 ? "down" : "up") |
161 | 161 | . "/*.sql"; |
162 | 162 | |
163 | - $result = array_filter(glob($filePattern), function ($file) use ($version) { |
|
163 | + $result = array_filter(glob($filePattern), function($file) use ($version) { |
|
164 | 164 | return preg_match("/^0*$version(-dev)?\.sql$/", basename($file)); |
165 | 165 | }); |
166 | 166 | |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | return $data; |
196 | 196 | } |
197 | 197 | |
198 | - $data["content"] = file_get_contents($file); |
|
198 | + $data[ "content" ] = file_get_contents($file); |
|
199 | 199 | |
200 | - if (preg_match("/--\s*@description:\s*(?<name>.*)/", $data["content"], $description)) { |
|
201 | - $data["description"] = $description["name"]; |
|
200 | + if (preg_match("/--\s*@description:\s*(?<name>.*)/", $data[ "content" ], $description)) { |
|
201 | + $data[ "description" ] = $description[ "name" ]; |
|
202 | 202 | } |
203 | 203 | |
204 | - $data["exists"] = true; |
|
205 | - $data["checksum"] = sha1($data["content"]); |
|
204 | + $data[ "exists" ] = true; |
|
205 | + $data[ "checksum" ] = sha1($data[ "content" ]); |
|
206 | 206 | |
207 | 207 | return $data; |
208 | 208 | } |
@@ -234,14 +234,14 @@ discard block |
||
234 | 234 | $fileInfo = $this->getFileContent($this->getBaseSql()); |
235 | 235 | |
236 | 236 | if ($this->callableProgress) { |
237 | - call_user_func_array($this->callableProgress, ['reset', 0, $fileInfo]); |
|
237 | + call_user_func_array($this->callableProgress, [ 'reset', 0, $fileInfo ]); |
|
238 | 238 | } |
239 | 239 | $this->getDbCommand()->dropDatabase(); |
240 | 240 | $this->getDbCommand()->createDatabase(); |
241 | 241 | $this->getDbCommand()->createVersion(); |
242 | 242 | |
243 | - if ($fileInfo["exists"]) { |
|
244 | - $this->getDbCommand()->executeSql($fileInfo["content"]); |
|
243 | + if ($fileInfo[ "exists" ]) { |
|
244 | + $this->getDbCommand()->executeSql($fileInfo[ "content" ]); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | $this->getDbCommand()->setVersion(0, Migration::VERSION_STATUS_COMPLETE); |
@@ -309,9 +309,9 @@ discard block |
||
309 | 309 | protected function migrate($upVersion, $increment, $force) |
310 | 310 | { |
311 | 311 | $versionInfo = $this->getCurrentVersion(); |
312 | - $currentVersion = intval($versionInfo['version']) + $increment; |
|
312 | + $currentVersion = intval($versionInfo[ 'version' ]) + $increment; |
|
313 | 313 | |
314 | - if (strpos($versionInfo['status'], Migration::VERSION_STATUS_PARTIAL) !== false && !$force) { |
|
314 | + if (strpos($versionInfo[ 'status' ], Migration::VERSION_STATUS_PARTIAL) !== false && !$force) { |
|
315 | 315 | throw new DatabaseIsIncompleteException('Database was not fully updated. Use --force for migrate.'); |
316 | 316 | } |
317 | 317 | |
@@ -319,16 +319,16 @@ discard block |
||
319 | 319 | ) { |
320 | 320 | $fileInfo = $this->getFileContent($this->getMigrationSql($currentVersion, $increment)); |
321 | 321 | |
322 | - if (!$fileInfo["exists"]) { |
|
322 | + if (!$fileInfo[ "exists" ]) { |
|
323 | 323 | break; |
324 | 324 | } |
325 | 325 | |
326 | 326 | if ($this->callableProgress) { |
327 | - call_user_func_array($this->callableProgress, ['migrate', $currentVersion, $fileInfo]); |
|
327 | + call_user_func_array($this->callableProgress, [ 'migrate', $currentVersion, $fileInfo ]); |
|
328 | 328 | } |
329 | 329 | |
330 | - $this->getDbCommand()->setVersion($currentVersion, Migration::VERSION_STATUS_PARTIAL . ' ' . ($increment>0 ? 'up' : 'down')); |
|
331 | - $this->getDbCommand()->executeSql($fileInfo["content"]); |
|
330 | + $this->getDbCommand()->setVersion($currentVersion, Migration::VERSION_STATUS_PARTIAL . ' ' . ($increment > 0 ? 'up' : 'down')); |
|
331 | + $this->getDbCommand()->executeSql($fileInfo[ "content" ]); |
|
332 | 332 | $this->getDbCommand()->setVersion($currentVersion, Migration::VERSION_STATUS_COMPLETE); |
333 | 333 | $currentVersion = $currentVersion + $increment; |
334 | 334 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | public function update($upVersion = null, $force = false) |
365 | 365 | { |
366 | 366 | $versionInfo = $this->getCurrentVersion(); |
367 | - $version = intval($versionInfo['version']); |
|
367 | + $version = intval($versionInfo[ 'version' ]); |
|
368 | 368 | $increment = 1; |
369 | 369 | if ($upVersion !== null && $upVersion < $version) { |
370 | 370 | $increment = -1; |
@@ -10,7 +10,7 @@ |
||
10 | 10 | { |
11 | 11 | public static function schema() |
12 | 12 | { |
13 | - return ['dblib', 'sqlsrv']; |
|
13 | + return [ 'dblib', 'sqlsrv' ]; |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | public static function prepareEnvironment(UriInterface $uri) |
@@ -10,7 +10,7 @@ |
||
10 | 10 | { |
11 | 11 | public static function schema() |
12 | 12 | { |
13 | - return ['mysql', 'mariadb']; |
|
13 | + return [ 'mysql', 'mariadb' ]; |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | public static function prepareEnvironment(UriInterface $uri) |