Skip to content
Snippets Groups Projects
Verified Commit 26b6d1b1 authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

chore: phpstan errors fixes


Signed-off-by: default avatarBart Jaskulski <bjaskulski@protonmail.com>
parent bb0b7d28
No related branches found
No related tags found
1 merge request!1is needed
......@@ -34,6 +34,7 @@ abstract class AbstractMigrationsRepository implements MigrationsRepository {
$this->migrations_source = $migrations_source;
}
/** @param class-string<AbstractMigration> $migration_class_name */
public function register_migration( string $migration_class_name ): void {
$migration = $this->version_factory->create_version( $migration_class_name );
$version = new Version( $migration_class_name );
......
......@@ -6,6 +6,7 @@ namespace WPDesk\Migrations;
class ArrayMigrationsRepository extends AbstractMigrationsRepository {
protected function load_migrations(): void {
/** @var class-string<AbstractMigration> $class */
foreach ( $this->migrations_source as $class ) {
$this->register_migration( $class );
}
......
......@@ -28,7 +28,7 @@ final class FilesystemMigrationsRepository extends AbstractMigrationsRepository
$this->migration_finder = $migration_finder;
}
/** @param string[] $migrations */
/** @param class-string<AbstractMigration>[] $migrations */
private function register_migrations( array $migrations ): void {
foreach ( $migrations as $migration ) {
$this->register_migration( $migration );
......
......@@ -33,7 +33,7 @@ final class GlobFinder implements MigrationFinder {
foreach ( $files as $file ) {
require_once $file;
$real_file = realpath( $file );
if ( ! $real_file ) {
if ( $real_file === false ) {
continue;
}
$included_files[] = $real_file;
......
......@@ -2,12 +2,11 @@
namespace WPDesk\Migrations;
use WPDesk\Migrations\Version\Version;
interface MigrationsRepository {
/** @return iterable<AvailableMigration> */
public function get_migrations(): iterable;
/** @param class-string<AbstractMigration> $migration_class_name */
public function register_migration( string $migration_class_name ): void;
}
......@@ -6,5 +6,6 @@ use WPDesk\Migrations\AbstractMigration;
interface MigrationFactory {
/** @param class-string<AbstractMigration> $migration_class */
public function create_version( string $migration_class ): AbstractMigration;
}
......@@ -20,8 +20,8 @@ class WpdbLogger implements \Psr\Log\LoggerInterface {
$this->log_name = $log_name;
}
public function log( $level, $message, array $context = [] ) {
if ( empty( $this->log ) ) {
public function log( $level, $message, array $context = [] ): void {
if ( count( $this->log ) === 0 ) {
$this->log = json_decode(
get_option(
$this->log_name,
......
......@@ -94,7 +94,7 @@ class WpdbMigrator implements Migrator {
if ( $last_migration === false ) {
return false;
}
if ( $this->comparator->compare( $last_migration->get_version(), $this->get_current_version() ) ) {
if ( $this->comparator->compare( $last_migration->get_version(), $this->get_current_version() ) > 0 ) {
return true;
}
return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment