diff --git a/composer.json b/composer.json index 3cfbac37a..217fa0163 100644 --- a/composer.json +++ b/composer.json @@ -74,7 +74,7 @@ "cs-check": "phpcs", "cs-fix": "phpcbf", "stan": "phpstan analyse", - "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:~1.12.0 && mv composer.backup composer.json", + "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:~2.1.0 && mv composer.backup composer.json", "lowest": "validate-prefer-lowest", "lowest-setup": "composer update --prefer-lowest --prefer-stable --prefer-dist --no-interaction && cp composer.json composer.backup && composer require --dev dereuromark/composer-prefer-lowest && mv composer.backup composer.json", "test": "phpunit --colors=always" diff --git a/src/Phinx/Db/Adapter/MysqlAdapter.php b/src/Phinx/Db/Adapter/MysqlAdapter.php index 4009ddb9e..bb7da9dc5 100644 --- a/src/Phinx/Db/Adapter/MysqlAdapter.php +++ b/src/Phinx/Db/Adapter/MysqlAdapter.php @@ -1463,7 +1463,7 @@ protected function getColumnSqlDefinition(Column $column): string } $values = $column->getValues(); - if ($values && is_array($values)) { + if ($values) { $def .= '(' . implode(', ', array_map(function ($value) { // we special case NULL as it's not actually allowed an enum value, // and we want MySQL to issue an error on the create statement, but diff --git a/src/Phinx/Db/Table/Index.php b/src/Phinx/Db/Table/Index.php index cea7b9520..87f8945f6 100644 --- a/src/Phinx/Db/Table/Index.php +++ b/src/Phinx/Db/Table/Index.php @@ -212,7 +212,7 @@ public function setOptions(array $options) } // handle $options['unique'] - if (strcasecmp($option, self::UNIQUE) === 0) { + if ($option === self::UNIQUE) { if ((bool)$value) { $this->setType(self::UNIQUE); } diff --git a/src/Phinx/Migration/Manager.php b/src/Phinx/Migration/Manager.php index 07c0a592a..b0d4a2b50 100644 --- a/src/Phinx/Migration/Manager.php +++ b/src/Phinx/Migration/Manager.php @@ -983,14 +983,8 @@ public function getSeeds(string $environment): array $seed = new $class(); } $seed->setEnvironment($environment); - $input = $this->getInput(); - if ($input !== null) { - $seed->setInput($input); - } - $output = $this->getOutput(); - if ($output !== null) { - $seed->setOutput($output); - } + $seed->setInput($this->getInput()); + $seed->setOutput($this->getOutput()); if (!($seed instanceof AbstractSeed)) { throw new InvalidArgumentException(sprintf( diff --git a/src/Phinx/Migration/Manager/Environment.php b/src/Phinx/Migration/Manager/Environment.php index 756206586..6181a383f 100644 --- a/src/Phinx/Migration/Manager/Environment.php +++ b/src/Phinx/Migration/Manager/Environment.php @@ -109,6 +109,14 @@ public function executeMigration(MigrationInterface $migration, string $directio $migration->{MigrationInterface::CHANGE}(); } } else { + if (!method_exists($migration, $direction)) { + throw new RuntimeException(sprintf( + 'Migration "%s" must define a %s() or %s() method.', + get_class($migration), + MigrationInterface::CHANGE, + $direction, + )); + } $migration->{$direction}(); } } @@ -143,9 +151,7 @@ public function executeSeed(SeedInterface $seed): void } // Run the seeder - if (method_exists($seed, SeedInterface::RUN)) { - $seed->{SeedInterface::RUN}(); - } + $seed->run(); // commit the transaction if the adapter supports it if ($this->getAdapter()->hasTransactions()) { diff --git a/src/Phinx/Seed/AbstractSeed.php b/src/Phinx/Seed/AbstractSeed.php index d9cdc9df3..a42be0d8c 100644 --- a/src/Phinx/Seed/AbstractSeed.php +++ b/src/Phinx/Seed/AbstractSeed.php @@ -188,9 +188,7 @@ public function fetchAll(string $sql): array public function insert(string $table, array $data): void { // convert to table object - if (is_string($table)) { - $table = new Table($table, [], $this->getAdapter()); - } + $table = new Table($table, [], $this->getAdapter()); $table->insert($data)->save(); }