Skip to content

Commit e76149e

Browse files
authored
Merge pull request #1585 from natanfelles/migration_versions
Type hint MigrationRunner methods
2 parents 5535126 + 3705ff8 commit e76149e

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

system/Database/MigrationRunner.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ public function __construct(BaseConfig $config, ConnectionInterface $db = null)
179179
* Calls each migration step required to get to the schema version of
180180
* choice
181181
*
182-
* @param integer $targetVersion Target schema version
182+
* @param string $targetVersion Target schema version
183183
* @param string|null $namespace
184184
* @param string|null $group
185185
*
186186
* @return mixed TRUE if no migrations are found, current version string on success, FALSE on failure
187187
* @throws ConfigException
188188
*/
189-
public function version(int $targetVersion, string $namespace = null, string $group = null)
189+
public function version(string $targetVersion, string $namespace = null, string $group = null)
190190
{
191191
if (! $this->enabled)
192192
{
@@ -277,12 +277,12 @@ public function version(int $targetVersion, string $namespace = null, string $gr
277277
/**
278278
* Sets the schema to the latest migration
279279
*
280-
* @param string $namespace
281-
* @param string $group
280+
* @param string|null $namespace
281+
* @param string|null $group
282282
*
283283
* @return mixed Current version string on success, FALSE on failure
284284
*/
285-
public function latest($namespace = null, $group = null)
285+
public function latest(string $namespace = null, string $group = null)
286286
{
287287
// Set Namespace if not null
288288
if (! is_null($namespace))
@@ -309,11 +309,11 @@ public function latest($namespace = null, $group = null)
309309
/**
310310
* Sets the schema to the latest migration for all namespaces
311311
*
312-
* @param string $group
312+
* @param string|null $group
313313
*
314314
* @return boolean
315315
*/
316-
public function latestAll($group = null)
316+
public function latestAll(string $group = null)
317317
{
318318
// Set database group if not null
319319
if (! is_null($group))
@@ -355,11 +355,11 @@ public function latestAll($group = null)
355355
/**
356356
* Sets the (APP_NAMESPACE) schema to $currentVersion in migration config file
357357
*
358-
* @param string $group
358+
* @param string|null $group
359359
*
360360
* @return mixed TRUE if no migrations are found, current version string on success, FALSE on failure
361361
*/
362-
public function current($group = null)
362+
public function current(string $group = null)
363363
{
364364
// Set database group if not null
365365
if (! is_null($group))
@@ -417,13 +417,13 @@ public function findMigrations()
417417
* if sequential check if no gaps and check if all consistent with migrations table if downgrading
418418
* if timestamp check if consistent with migrations table if downgrading
419419
*
420-
* @param array $migrations
421-
* @param string $method
422-
* @param integer $targetversion
420+
* @param array $migrations
421+
* @param string $method
422+
* @param string $targetversion
423423
*
424424
* @return boolean
425425
*/
426-
protected function checkMigrations(array $migrations, string $method, int $targetversion)
426+
protected function checkMigrations(array $migrations, string $method, string $targetversion)
427427
{
428428
// Check if no migrations found
429429
if (empty($migrations))
@@ -436,7 +436,7 @@ protected function checkMigrations(array $migrations, string $method, int $targe
436436
}
437437

438438
// Check if $targetversion file is found
439-
if ($targetversion !== 0 && ! array_key_exists($targetversion, $migrations))
439+
if ($targetversion !== '0' && ! array_key_exists($targetversion, $migrations))
440440
{
441441
if ($this->silent)
442442
{
@@ -529,7 +529,7 @@ public function setName(string $name)
529529
*
530530
* @return array
531531
*/
532-
public function getHistory($group = 'default')
532+
public function getHistory(string $group = 'default')
533533
{
534534
$query = $this->db->table($this->table)
535535
->where('group', $group)
@@ -571,7 +571,7 @@ public function setSilent(bool $silent)
571571
*
572572
* @return string Numeric portion of a migration filename
573573
*/
574-
protected function getMigrationNumber($migration)
574+
protected function getMigrationNumber(string $migration)
575575
{
576576
return sscanf($migration, '%[0-9]+', $number) ? $number : '0';
577577
}
@@ -585,7 +585,7 @@ protected function getMigrationNumber($migration)
585585
*
586586
* @return string text portion of a migration filename
587587
*/
588-
protected function getMigrationName($migration)
588+
protected function getMigrationName(string $migration)
589589
{
590590
$parts = explode('_', $migration);
591591
array_shift($parts);
@@ -633,7 +633,7 @@ public function getCliMessages()
633633
*
634634
* @internal param string $migration Migration reached
635635
*/
636-
protected function addHistory($version)
636+
protected function addHistory(string $version)
637637
{
638638
$this->db->table($this->table)
639639
->insert([
@@ -656,7 +656,7 @@ protected function addHistory($version)
656656
*
657657
* @param string $version
658658
*/
659-
protected function removeHistory($version)
659+
protected function removeHistory(string $version)
660660
{
661661
$this->db->table($this->table)
662662
->where('version', $version)

0 commit comments

Comments
 (0)