diff --git a/src/AbstractMigrationsRepository.php b/src/AbstractMigrationsRepository.php index d4eb634b74c54ccd681668cdd215867ea90106aa..7ed454597ebd52c3be2c09b44b5a31b1657f2333 100644 --- a/src/AbstractMigrationsRepository.php +++ b/src/AbstractMigrationsRepository.php @@ -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 ); diff --git a/src/ArrayMigrationsRepository.php b/src/ArrayMigrationsRepository.php index 531b3125c315fbe31e86536345e830964e578b83..05e42450e63819ecb4ccaef07b1569f423633fcc 100644 --- a/src/ArrayMigrationsRepository.php +++ b/src/ArrayMigrationsRepository.php @@ -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 ); } diff --git a/src/FilesystemMigrationsRepository.php b/src/FilesystemMigrationsRepository.php index 83d1f017de89ff36b0e419f274ac0aa98880098e..b3b91c25abfa0c037ce9a8d9f19373d3cc5e3e3d 100644 --- a/src/FilesystemMigrationsRepository.php +++ b/src/FilesystemMigrationsRepository.php @@ -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 ); diff --git a/src/Finder/GlobFinder.php b/src/Finder/GlobFinder.php index a1ba30049adaa6364cd5d5afd3d5bb00ea019889..69c868ba92e84242a2cfcee21a518fd875e2a219 100644 --- a/src/Finder/GlobFinder.php +++ b/src/Finder/GlobFinder.php @@ -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; diff --git a/src/MigrationsRepository.php b/src/MigrationsRepository.php index 72e38178612a41c9d7c3f517937cd9516ee174e6..119cd35becc813b198789c4911c9a05f4756ff2f 100644 --- a/src/MigrationsRepository.php +++ b/src/MigrationsRepository.php @@ -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; } diff --git a/src/Version/MigrationFactory.php b/src/Version/MigrationFactory.php index 5c0827922f2b0572573d4d55ab5b53fa2984c1c9..397ef78740bf4174f197f21ee5c6b8b74b0c7972 100644 --- a/src/Version/MigrationFactory.php +++ b/src/Version/MigrationFactory.php @@ -6,5 +6,6 @@ use WPDesk\Migrations\AbstractMigration; interface MigrationFactory { + /** @param class-string<AbstractMigration> $migration_class */ public function create_version( string $migration_class ): AbstractMigration; } diff --git a/src/WpdbLogger.php b/src/WpdbLogger.php index 47119c0d76e99f3d4defc5f144ef208e9fb9156c..f15b8211e084d4fa3ffaf5a0222f46efcfff36b5 100644 --- a/src/WpdbLogger.php +++ b/src/WpdbLogger.php @@ -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, diff --git a/src/WpdbMigrator.php b/src/WpdbMigrator.php index bf896e1cd13a79b3e8ece70ba5590e7f0bbcd5d9..33b40dc4a8c9a8a7a6981fcca683042d6fe51751 100644 --- a/src/WpdbMigrator.php +++ b/src/WpdbMigrator.php @@ -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;