@@ -167,7 +167,6 @@ public function __construct(BaseConfig $config, $db = null)
167167 * Locate and run all new migrations
168168 *
169169 * @param string|null $group
170- *
171170 */
172171 public function progress (string $ group = null )
173172 {
@@ -210,7 +209,8 @@ public function progress(string $group = null)
210209 $ this ->addHistory ($ migration , $ batch );
211210 }
212211 // If a migration failed then try to back out what was done
213- else {
212+ else
213+ {
214214 $ this ->regress (-1 );
215215
216216 $ message = lang ('Migrations.generalFault ' );
@@ -234,13 +234,13 @@ public function progress(string $group = null)
234234 *
235235 * Calls each migration step required to get to the provided batch
236236 *
237- * @param int $targetBatch Target batch number, or negative for a relative batch, 0 for all
237+ * @param integer $targetBatch Target batch number, or negative for a relative batch, 0 for all
238238 * @param string|null $group
239239 *
240240 * @return mixed Current batch number on success, FALSE on failure or no migrations are found
241241 * @throws ConfigException
242242 */
243- public function regress (int $ targetBatch , string $ group = null )
243+ public function regress (int $ targetBatch = 0 , string $ group = null )
244244 {
245245 if (! $ this ->enabled )
246246 {
@@ -285,7 +285,7 @@ public function regress(int $targetBatch, string $group = null)
285285
286286 // Get all migrations
287287 $ this ->namespace = null ;
288- $ allMigrations = $ this ->findMigrations ();
288+ $ allMigrations = $ this ->findMigrations ();
289289
290290 // Gather migrations down through each batch until reaching the target
291291 $ migrations = [];
@@ -317,9 +317,9 @@ public function regress(int $targetBatch, string $group = null)
317317 }
318318
319319 // Add the history and put it on the list
320- $ migration = $ allMigrations [$ uid ];
320+ $ migration = $ allMigrations [$ uid ];
321321 $ migration ->history = $ history ;
322- $ migrations [] = $ migration ;
322+ $ migrations [] = $ migration ;
323323 }
324324 }
325325
@@ -331,7 +331,8 @@ public function regress(int $targetBatch, string $group = null)
331331 $ this ->removeHistory ($ migration ->history );
332332 }
333333 // If a migration failed then quit so as not to ruin the whole batch
334- else {
334+ else
335+ {
335336 $ message = lang ('Migrations.generalFault ' );
336337
337338 if ($ this ->silent )
@@ -353,10 +354,9 @@ public function regress(int $targetBatch, string $group = null)
353354 * Method "up" or "down" determined by presence in history.
354355 * NOTE: This is not recommended and provided mostly for testing.
355356 *
356- * @param string $path Full path to a valid migration file
357- * @param string $path Namespace of the target migration
357+ * @param string $path Full path to a valid migration file
358+ * @param string $path Namespace of the target migration
358359 * @param string|null $group
359- *
360360 */
361361 public function force (string $ path , string $ namespace , string $ group = null )
362362 {
@@ -392,16 +392,16 @@ public function force(string $path, string $namespace, string $group = null)
392392 $ this ->setNamespace ($ migration ->namespace );
393393 foreach ($ this ->getHistory ($ this ->group ) as $ history )
394394 {
395- if ($ this ->getObjectUid ($ history ) == $ migration ->uid )
395+ if ($ this ->getObjectUid ($ history ) === $ migration ->uid )
396396 {
397- $ method = 'down ' ;
397+ $ method = 'down ' ;
398398 $ migration ->history = $ history ;
399399 break ;
400400 }
401401 }
402402
403403 // up
404- if ($ method == 'up ' )
404+ if ($ method === 'up ' )
405405 {
406406 // Start a new batch
407407 $ batch = $ this ->getLastBatch () + 1 ;
@@ -464,7 +464,7 @@ public function findMigrations(): array
464464 /**
465465 * Retrieves a list of available migration scripts for one namespace
466466 *
467- * @param string $namespace The namespace to search for migrations
467+ * @param string $namespace The namespace to search for migrations
468468 *
469469 * @return array List of unsorted migrations from the namespace
470470 */
@@ -508,8 +508,8 @@ public function findNamespaceMigrations(string $namespace): array
508508 /**
509509 * Create a migration object from a file path.
510510 *
511- * @param string $path The path to the file
512- * @param string $path The namespace of the target migration
511+ * @param string $path The path to the file
512+ * @param string $path The namespace of the target migration
513513 *
514514 * @return object|false Returns the migration object, or false on failure
515515 */
@@ -551,7 +551,7 @@ protected function migrationFromFile(string $path, string $namespace)
551551 * Set namespace.
552552 * Allows other scripts to modify on the fly as needed.
553553 *
554- * @param ? string $namespace or null for "all"
554+ * @param string $namespace or null for "all"
555555 *
556556 * @return MigrationRunner
557557 */
@@ -710,7 +710,7 @@ public function clearHistory()
710710 * @param object $migration
711711 * @param integer $batch
712712 *
713- * @return void
713+ * @return void
714714 */
715715 protected function addHistory ($ migration , int $ batch )
716716 {
@@ -742,7 +742,6 @@ protected function addHistory($migration, int $batch)
742742 */
743743 protected function removeHistory ($ history )
744744 {
745-
746745 $ this ->db ->table ($ this ->table )->where ('id ' , $ history ->id )->delete ();
747746
748747 if (is_cli ())
@@ -795,9 +794,9 @@ public function getBatchHistory(int $batch): array
795794 $ this ->ensureTable ();
796795
797796 $ query = $ this ->db ->table ($ this ->table )
798- ->where ('batch ' , $ batch )
799- ->orderBy ('id ' , 'asc ' )
800- ->get ();
797+ ->where ('batch ' , $ batch )
798+ ->orderBy ('id ' , 'asc ' )
799+ ->get ();
801800
802801 return $ query ? $ query ->getResultObject () : [];
803802 }
@@ -816,7 +815,7 @@ public function getBatches(): array
816815 $ batches = $ this ->db ->table ($ this ->table )
817816 ->select ('batch ' )
818817 ->distinct ()
819- ->orderBy ('batch ' , 'asc ' )
818+ ->orderBy ('batch ' , 'asc ' )
820819 ->get ()
821820 ->getResultArray ();
822821
@@ -862,7 +861,7 @@ public function getBatchStart(int $batch): string
862861 if ($ batch < 0 )
863862 {
864863 $ batches = $ this ->getBatches ();
865- $ batch = $ batches [count ($ batches ) - 1 + $ targetBatch ] ?? 0 ;
864+ $ batch = $ batches [count ($ batches ) - 1 + $ targetBatch ] ?? 0 ;
866865 }
867866
868867 $ migration = $ this ->db ->table ($ this ->table )
@@ -891,7 +890,7 @@ public function getBatchEnd(int $batch): string
891890 if ($ batch < 0 )
892891 {
893892 $ batches = $ this ->getBatches ();
894- $ batch = $ batches [count ($ batches ) - 1 + $ targetBatch ] ?? 0 ;
893+ $ batch = $ batches [count ($ batches ) - 1 + $ targetBatch ] ?? 0 ;
895894 }
896895
897896 $ migration = $ this ->db ->table ($ this ->table )
0 commit comments