Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:~1.12.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"
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Variable \\$tval on left side of \\?\\? always exists and is not nullable\\.$#"
count: 1
path: src/Phinx/Config/Config.php

-
message: "#^Expression on left side of \\?\\? is not nullable\\.$#"
count: 1
Expand Down
4 changes: 2 additions & 2 deletions src/Phinx/Db/Adapter/SQLiteAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1168,8 +1168,8 @@ protected function calculateNewTableColumns(string $tableName, string|false $col
$writeColumns[] = $writeName;
}

$selectColumns = array_filter($selectColumns, 'strlen');
$writeColumns = array_filter($writeColumns, 'strlen');
$selectColumns = array_filter($selectColumns, fn($v) => $v && strlen($v) > 0);
$writeColumns = array_filter($writeColumns, fn($v) => $v && strlen($v) > 0);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per phpstan/phpstan#2266, the maintainer of phpstan made a conscious decision to encode this where the callable passed to array_filter must return a boolean value (I think), which strlen doesn't do.

Passing 'strlen' would also implicitly filter out both emtpy strings and false values, whereas doing it explicitly throws a type error passing a boolean to strlen, so this is certainly more type safe in general I guess.

$selectColumns = array_map([$this, 'quoteColumnName'], $selectColumns);
$writeColumns = array_map([$this, 'quoteColumnName'], $writeColumns);

Expand Down