From 47c5f82853d568867adf10dcd5d4d8eb91eb7084 Mon Sep 17 00:00:00 2001 From: Matthew Peveler Date: Mon, 9 Jun 2025 20:49:03 -0600 Subject: [PATCH 1/3] Update phpstan to 2.1.x Signed-off-by: Matthew Peveler --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4fa95419e..a94cd6995 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.9.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" From 09b4a25475cba6d45773a7351658be40cc81e7ad Mon Sep 17 00:00:00 2001 From: Matthew Peveler Date: Mon, 9 Jun 2025 20:51:31 -0600 Subject: [PATCH 2/3] Remove removed parameters --- phpstan.neon | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 703cfce6e..be21d83c8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,8 +4,6 @@ includes: parameters: level: 6 treatPhpDocTypesAsCertain: false - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false paths: - src/ ignoreErrors: From 37fba354b042e8a4f3e95003502139118c058eb2 Mon Sep 17 00:00:00 2001 From: Matthew Peveler Date: Fri, 3 Jul 2026 06:39:31 +0000 Subject: [PATCH 3/3] fix phpstan errors --- src/Phinx/Db/Adapter/MysqlAdapter.php | 2 +- src/Phinx/Db/Table/Index.php | 2 +- src/Phinx/Migration/Manager.php | 10 ++-------- src/Phinx/Migration/Manager/Environment.php | 12 +++++++++--- src/Phinx/Seed/AbstractSeed.php | 4 +--- 5 files changed, 14 insertions(+), 16 deletions(-) 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(); }