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 { ...@@ -34,6 +34,7 @@ abstract class AbstractMigrationsRepository implements MigrationsRepository {
$this->migrations_source = $migrations_source; $this->migrations_source = $migrations_source;
} }
/** @param class-string<AbstractMigration> $migration_class_name */
public function register_migration( string $migration_class_name ): void { public function register_migration( string $migration_class_name ): void {
$migration = $this->version_factory->create_version( $migration_class_name ); $migration = $this->version_factory->create_version( $migration_class_name );
$version = new Version( $migration_class_name ); $version = new Version( $migration_class_name );
......
...@@ -6,6 +6,7 @@ namespace WPDesk\Migrations; ...@@ -6,6 +6,7 @@ namespace WPDesk\Migrations;
class ArrayMigrationsRepository extends AbstractMigrationsRepository { class ArrayMigrationsRepository extends AbstractMigrationsRepository {
protected function load_migrations(): void { protected function load_migrations(): void {
/** @var class-string<AbstractMigration> $class */
foreach ( $this->migrations_source as $class ) { foreach ( $this->migrations_source as $class ) {
$this->register_migration( $class ); $this->register_migration( $class );
} }
......
...@@ -28,7 +28,7 @@ final class FilesystemMigrationsRepository extends AbstractMigrationsRepository ...@@ -28,7 +28,7 @@ final class FilesystemMigrationsRepository extends AbstractMigrationsRepository
$this->migration_finder = $migration_finder; $this->migration_finder = $migration_finder;
} }
/** @param string[] $migrations */ /** @param class-string<AbstractMigration>[] $migrations */
private function register_migrations( array $migrations ): void { private function register_migrations( array $migrations ): void {
foreach ( $migrations as $migration ) { foreach ( $migrations as $migration ) {
$this->register_migration( $migration ); $this->register_migration( $migration );
......
...@@ -33,7 +33,7 @@ final class GlobFinder implements MigrationFinder { ...@@ -33,7 +33,7 @@ final class GlobFinder implements MigrationFinder {
foreach ( $files as $file ) { foreach ( $files as $file ) {
require_once $file; require_once $file;
$real_file = realpath( $file ); $real_file = realpath( $file );
if ( ! $real_file ) { if ( $real_file === false ) {
continue; continue;
} }
$included_files[] = $real_file; $included_files[] = $real_file;
......
...@@ -2,12 +2,11 @@ ...@@ -2,12 +2,11 @@
namespace WPDesk\Migrations; namespace WPDesk\Migrations;
use WPDesk\Migrations\Version\Version;
interface MigrationsRepository { interface MigrationsRepository {
/** @return iterable<AvailableMigration> */ /** @return iterable<AvailableMigration> */
public function get_migrations(): iterable; public function get_migrations(): iterable;
/** @param class-string<AbstractMigration> $migration_class_name */
public function register_migration( string $migration_class_name ): void; public function register_migration( string $migration_class_name ): void;
} }
...@@ -6,5 +6,6 @@ use WPDesk\Migrations\AbstractMigration; ...@@ -6,5 +6,6 @@ use WPDesk\Migrations\AbstractMigration;
interface MigrationFactory { interface MigrationFactory {
/** @param class-string<AbstractMigration> $migration_class */
public function create_version( string $migration_class ): AbstractMigration; public function create_version( string $migration_class ): AbstractMigration;
} }
...@@ -20,8 +20,8 @@ class WpdbLogger implements \Psr\Log\LoggerInterface { ...@@ -20,8 +20,8 @@ class WpdbLogger implements \Psr\Log\LoggerInterface {
$this->log_name = $log_name; $this->log_name = $log_name;
} }
public function log( $level, $message, array $context = [] ) { public function log( $level, $message, array $context = [] ): void {
if ( empty( $this->log ) ) { if ( count( $this->log ) === 0 ) {
$this->log = json_decode( $this->log = json_decode(
get_option( get_option(
$this->log_name, $this->log_name,
......
...@@ -94,7 +94,7 @@ class WpdbMigrator implements Migrator { ...@@ -94,7 +94,7 @@ class WpdbMigrator implements Migrator {
if ( $last_migration === false ) { if ( $last_migration === false ) {
return 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 true;
} }
return false; 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