Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type hint MigrationRunner methods #1585

Merged
merged 3 commits into from
Dec 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions system/Database/MigrationRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ public function __construct(BaseConfig $config, ConnectionInterface $db = null)
* Calls each migration step required to get to the schema version of
* choice
*
* @param integer $targetVersion Target schema version
* @param string $targetVersion Target schema version
* @param string|null $namespace
* @param string|null $group
*
* @return mixed TRUE if no migrations are found, current version string on success, FALSE on failure
* @throws ConfigException
*/
public function version(int $targetVersion, string $namespace = null, string $group = null)
public function version(string $targetVersion, string $namespace = null, string $group = null)
{
if (! $this->enabled)
{
Expand Down Expand Up @@ -277,12 +277,12 @@ public function version(int $targetVersion, string $namespace = null, string $gr
/**
* Sets the schema to the latest migration
*
* @param string $namespace
* @param string $group
* @param string|null $namespace
* @param string|null $group
*
* @return mixed Current version string on success, FALSE on failure
*/
public function latest($namespace = null, $group = null)
public function latest(string $namespace = null, string $group = null)
{
// Set Namespace if not null
if (! is_null($namespace))
Expand All @@ -309,11 +309,11 @@ public function latest($namespace = null, $group = null)
/**
* Sets the schema to the latest migration for all namespaces
*
* @param string $group
* @param string|null $group
*
* @return boolean
*/
public function latestAll($group = null)
public function latestAll(string $group = null)
{
// Set database group if not null
if (! is_null($group))
Expand Down Expand Up @@ -355,11 +355,11 @@ public function latestAll($group = null)
/**
* Sets the (APP_NAMESPACE) schema to $currentVersion in migration config file
*
* @param string $group
* @param string|null $group
*
* @return mixed TRUE if no migrations are found, current version string on success, FALSE on failure
*/
public function current($group = null)
public function current(string $group = null)
{
// Set database group if not null
if (! is_null($group))
Expand Down Expand Up @@ -417,13 +417,13 @@ public function findMigrations()
* if sequential check if no gaps and check if all consistent with migrations table if downgrading
* if timestamp check if consistent with migrations table if downgrading
*
* @param array $migrations
* @param string $method
* @param integer $targetversion
* @param array $migrations
* @param string $method
* @param string $targetversion
*
* @return boolean
*/
protected function checkMigrations(array $migrations, string $method, int $targetversion)
protected function checkMigrations(array $migrations, string $method, string $targetversion)
{
// Check if no migrations found
if (empty($migrations))
Expand All @@ -436,7 +436,7 @@ protected function checkMigrations(array $migrations, string $method, int $targe
}

// Check if $targetversion file is found
if ($targetversion !== 0 && ! array_key_exists($targetversion, $migrations))
if ($targetversion !== '0' && ! array_key_exists($targetversion, $migrations))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String needed because the Coding Standard forces strict comparisons !==.

{
if ($this->silent)
{
Expand Down Expand Up @@ -529,7 +529,7 @@ public function setName(string $name)
*
* @return array
*/
public function getHistory($group = 'default')
public function getHistory(string $group = 'default')
{
$query = $this->db->table($this->table)
->where('group', $group)
Expand Down Expand Up @@ -571,7 +571,7 @@ public function setSilent(bool $silent)
*
* @return string Numeric portion of a migration filename
*/
protected function getMigrationNumber($migration)
protected function getMigrationNumber(string $migration)
{
return sscanf($migration, '%[0-9]+', $number) ? $number : '0';
}
Expand All @@ -585,7 +585,7 @@ protected function getMigrationNumber($migration)
*
* @return string text portion of a migration filename
*/
protected function getMigrationName($migration)
protected function getMigrationName(string $migration)
{
$parts = explode('_', $migration);
array_shift($parts);
Expand Down Expand Up @@ -633,7 +633,7 @@ public function getCliMessages()
*
* @internal param string $migration Migration reached
*/
protected function addHistory($version)
protected function addHistory(string $version)
{
$this->db->table($this->table)
->insert([
Expand All @@ -656,7 +656,7 @@ protected function addHistory($version)
*
* @param string $version
*/
protected function removeHistory($version)
protected function removeHistory(string $version)
{
$this->db->table($this->table)
->where('version', $version)
Expand Down