Fix phpstan claims & php code sniffer errors

This commit is contained in:
Yonas Habteab 2023-09-13 14:59:22 +02:00 committed by Johannes Meyer
parent a167b6d21a
commit 73b1041816
2 changed files with 11 additions and 6 deletions

View File

@ -203,8 +203,8 @@ class MigrationsController extends CompatController
} else { } else {
Notification::error( Notification::error(
$this->translate( $this->translate(
'Applied migrations successfully. Though, one or more migration hooks failed to run.' 'Applied migrations successfully. Though, one or more migration hooks'
. ' See logs for details' . ' failed to run. See logs for details'
) )
); );
} }

View File

@ -86,7 +86,8 @@ abstract class MigrationHook implements Countable
{ {
$pdoStmt = $conn->prepexec( $pdoStmt = $conn->prepexec(
sprintf( sprintf(
"SELECT %s AS column_type, %s AS column_length FROM information_schema.columns WHERE table_name = ? AND column_name = ?", 'SELECT %s AS column_type, %s AS column_length FROM information_schema.columns'
. ' WHERE table_name = ? AND column_name = ?',
$conn->getAdapter() instanceof Pgsql ? 'udt_name' : 'column_type', $conn->getAdapter() instanceof Pgsql ? 'udt_name' : 'column_type',
$conn->getAdapter() instanceof Pgsql ? 'character_maximum_length' : 'NULL' $conn->getAdapter() instanceof Pgsql ? 'character_maximum_length' : 'NULL'
), ),
@ -140,7 +141,7 @@ abstract class MigrationHook implements Countable
$this->load(); $this->load();
} }
return $this->migrations; return $this->migrations ?? [];
} }
/** /**
@ -289,8 +290,12 @@ abstract class MigrationHook implements Countable
} }
} }
// Sort all the migrations by their version numbers in ascending order. if ($this->migrations) {
uksort($this->migrations, 'version_compare'); // Sort all the migrations by their version numbers in ascending order.
uksort($this->migrations, function ($a, $b) {
return version_compare($a, $b);
});
}
} }
/** /**