Skip to content

Commit cee764e

Browse files
authored
Update phpstan to 2.1.x (#2362)
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
1 parent d359d56 commit cee764e

6 files changed

Lines changed: 15 additions & 17 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"cs-check": "phpcs",
7575
"cs-fix": "phpcbf",
7676
"stan": "phpstan analyse",
77-
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:~1.12.0 && mv composer.backup composer.json",
77+
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:~2.1.0 && mv composer.backup composer.json",
7878
"lowest": "validate-prefer-lowest",
7979
"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",
8080
"test": "phpunit --colors=always"

src/Phinx/Db/Adapter/MysqlAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ protected function getColumnSqlDefinition(Column $column): string
14631463
}
14641464

14651465
$values = $column->getValues();
1466-
if ($values && is_array($values)) {
1466+
if ($values) {
14671467
$def .= '(' . implode(', ', array_map(function ($value) {
14681468
// we special case NULL as it's not actually allowed an enum value,
14691469
// and we want MySQL to issue an error on the create statement, but

src/Phinx/Db/Table/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public function setOptions(array $options)
212212
}
213213

214214
// handle $options['unique']
215-
if (strcasecmp($option, self::UNIQUE) === 0) {
215+
if ($option === self::UNIQUE) {
216216
if ((bool)$value) {
217217
$this->setType(self::UNIQUE);
218218
}

src/Phinx/Migration/Manager.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -983,14 +983,8 @@ public function getSeeds(string $environment): array
983983
$seed = new $class();
984984
}
985985
$seed->setEnvironment($environment);
986-
$input = $this->getInput();
987-
if ($input !== null) {
988-
$seed->setInput($input);
989-
}
990-
$output = $this->getOutput();
991-
if ($output !== null) {
992-
$seed->setOutput($output);
993-
}
986+
$seed->setInput($this->getInput());
987+
$seed->setOutput($this->getOutput());
994988

995989
if (!($seed instanceof AbstractSeed)) {
996990
throw new InvalidArgumentException(sprintf(

src/Phinx/Migration/Manager/Environment.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ public function executeMigration(MigrationInterface $migration, string $directio
109109
$migration->{MigrationInterface::CHANGE}();
110110
}
111111
} else {
112+
if (!method_exists($migration, $direction)) {
113+
throw new RuntimeException(sprintf(
114+
'Migration "%s" must define a %s() or %s() method.',
115+
get_class($migration),
116+
MigrationInterface::CHANGE,
117+
$direction,
118+
));
119+
}
112120
$migration->{$direction}();
113121
}
114122
}
@@ -143,9 +151,7 @@ public function executeSeed(SeedInterface $seed): void
143151
}
144152

145153
// Run the seeder
146-
if (method_exists($seed, SeedInterface::RUN)) {
147-
$seed->{SeedInterface::RUN}();
148-
}
154+
$seed->run();
149155

150156
// commit the transaction if the adapter supports it
151157
if ($this->getAdapter()->hasTransactions()) {

src/Phinx/Seed/AbstractSeed.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,7 @@ public function fetchAll(string $sql): array
188188
public function insert(string $table, array $data): void
189189
{
190190
// convert to table object
191-
if (is_string($table)) {
192-
$table = new Table($table, [], $this->getAdapter());
193-
}
191+
$table = new Table($table, [], $this->getAdapter());
194192
$table->insert($data)->save();
195193
}
196194

0 commit comments

Comments
 (0)