aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/tests.yml4
-rw-r--r--app/Controllers/configureController.php2
-rwxr-xr-xapp/Controllers/feedController.php2
-rw-r--r--app/Controllers/subscriptionController.php4
-rw-r--r--app/Models/Entry.php2
-rw-r--r--app/Models/UserQuery.php2
-rw-r--r--cli/CliOption.php4
-rw-r--r--cli/CliOptionsParser.php4
-rwxr-xr-xcli/create-user.php2
-rwxr-xr-xcli/reconfigure.php3
-rwxr-xr-xcli/update-user.php2
-rw-r--r--composer.json3
-rw-r--r--lib/Minz/Migrator.php2
-rw-r--r--lib/lib_rss.php4
-rw-r--r--phpstan-next.neon14
-rw-r--r--phpstan.dist.neon5
16 files changed, 25 insertions, 34 deletions
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 4517c9505..dd159ff1f 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -49,8 +49,8 @@ jobs:
- name: PHPStan
run: composer run-script phpstan
- - name: PHPStan Next
- run: composer run-script phpstan-next
+ # - name: PHPStan Next
+ # run: composer run-script phpstan-next
# NPM tests
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php
index dc5407e99..6c1561d7c 100644
--- a/app/Controllers/configureController.php
+++ b/app/Controllers/configureController.php
@@ -386,7 +386,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
$this->view->tags = FreshRSS_Context::labels();
if (Minz_Request::isPost()) {
- $params = array_filter(Minz_Request::paramArray('query'));
+ $params = Minz_Request::paramArray('query');
$queryParams = [];
$name = Minz_Request::paramString('name') ?: _t('conf.query.number', $id + 1);
if ('' === $name) {
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 977143882..97d68883c 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -221,7 +221,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
}
}
- $headers = array_filter(array_map('trim', $headers));
+ $headers = array_filter($headers, fn(string $header): bool => trim($header) !== '');
if (!empty($headers)) {
$opts[CURLOPT_HTTPHEADER] = array_merge($headers, $opts[CURLOPT_HTTPHEADER] ?? []);
$opts[CURLOPT_HTTPHEADER] = array_unique($opts[CURLOPT_HTTPHEADER]);
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php
index 70065fc26..424b9a776 100644
--- a/app/Controllers/subscriptionController.php
+++ b/app/Controllers/subscriptionController.php
@@ -207,7 +207,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
}
}
- $headers = array_filter(array_map('trim', $headers));
+ $headers = array_filter($headers, fn(string $header): bool => trim($header) !== '');
if (!empty($headers)) {
$opts[CURLOPT_HTTPHEADER] = array_merge($headers, $opts[CURLOPT_HTTPHEADER] ?? []);
$opts[CURLOPT_HTTPHEADER] = array_unique($opts[CURLOPT_HTTPHEADER]);
@@ -318,7 +318,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
}
$conditions = Minz_Request::paramTextToArray('path_entries_conditions', plaintext: true);
- $conditions = array_filter(array_map('trim', $conditions));
+ $conditions = array_filter($conditions, fn(string $condition): bool => trim($condition) !== '');
$feed->_attribute('path_entries_conditions', empty($conditions) ? null : $conditions);
$feed->_attribute('path_entries_filter', Minz_Request::paramString('path_entries_filter', true));
diff --git a/app/Models/Entry.php b/app/Models/Entry.php
index 7ba0d3793..7254dd513 100644
--- a/app/Models/Entry.php
+++ b/app/Models/Entry.php
@@ -860,7 +860,7 @@ HTML;
}
$conditions = $feed->attributeArray('path_entries_conditions') ?? [];
- $conditions = array_filter(array_map(fn($v) => is_string($v) ? trim($v) : '', $conditions));
+ $conditions = array_filter($conditions, fn($v): bool => (is_string($v) ? trim($v) : '') !== '');
if (count($conditions) > 0) {
$found = false;
foreach ($conditions as $condition) {
diff --git a/app/Models/UserQuery.php b/app/Models/UserQuery.php
index 196d0126e..c78eeccd3 100644
--- a/app/Models/UserQuery.php
+++ b/app/Models/UserQuery.php
@@ -124,7 +124,7 @@ class FreshRSS_UserQuery {
'shareOpml' => $this->shareOpml,
'description' => $this->description,
'imageUrl' => $this->imageUrl,
- ]);
+ ], fn($v): bool => $v !== '' && $v !== 0 && $v !== false);
}
/**
diff --git a/cli/CliOption.php b/cli/CliOption.php
index e92fbd804..129d0de03 100644
--- a/cli/CliOption.php
+++ b/cli/CliOption.php
@@ -5,6 +5,7 @@ final class CliOption {
public const VALUE_NONE = 'none';
public const VALUE_REQUIRED = 'required';
public const VALUE_OPTIONAL = 'optional';
+ /** @var 'none'|'required'|'optional' $valueTaken */
private string $valueTaken = self::VALUE_REQUIRED;
/** @var array{type:string,isArray:bool} $types */
private array $types = ['type' => 'string', 'isArray' => false];
@@ -61,6 +62,7 @@ final class CliOption {
return $this;
}
+ /** @return 'none'|'required'|'optional' */
public function getValueTaken(): string {
return $this->valueTaken;
}
@@ -94,6 +96,6 @@ final class CliOption {
$this->deprecatedAlias,
];
- return array_filter($aliases);
+ return array_filter($aliases, fn(?string $alias): bool => $alias !== null && trim($alias) !== '');
}
}
diff --git a/cli/CliOptionsParser.php b/cli/CliOptionsParser.php
index e1a697e35..9ef9e9f10 100644
--- a/cli/CliOptionsParser.php
+++ b/cli/CliOptionsParser.php
@@ -216,8 +216,8 @@ abstract class CliOptionsParser {
}
return [
- 'long' => array_filter($long),
- 'short' => $short
+ 'long' => array_filter($long, fn(string $v): bool => trim($v) !== ''),
+ 'short' => $short,
];
}
diff --git a/cli/create-user.php b/cli/create-user.php
index cbcc89ba4..0276e80b3 100755
--- a/cli/create-user.php
+++ b/cli/create-user.php
@@ -75,7 +75,7 @@ $values = [
'max_posts_per_rss' => $cliOptions->maxPostsPerRss ?? null,
];
-$values = array_filter($values);
+$values = array_filter($values, fn($v): bool => $v !== null && $v !== '');
$ok = FreshRSS_user_Controller::createUser(
$username,
diff --git a/cli/reconfigure.php b/cli/reconfigure.php
index ef86516f9..f2c86a8d4 100755
--- a/cli/reconfigure.php
+++ b/cli/reconfigure.php
@@ -113,7 +113,8 @@ foreach ($values as $name => $value) {
}
}
-$db = array_merge(FreshRSS_Context::systemConf()->db, array_filter($dbValues));
+$db = array_merge(FreshRSS_Context::systemConf()->db,
+ array_filter($dbValues, fn(?string $v): bool => $v !== null && trim($v) !== ''));
performRequirementCheck($db['type']);
diff --git a/cli/update-user.php b/cli/update-user.php
index 946f296fa..7e50503b9 100755
--- a/cli/update-user.php
+++ b/cli/update-user.php
@@ -66,7 +66,7 @@ $values = [
'max_posts_per_rss' => $cliOptions->maxPostsPerRss ?? null,
];
-$values = array_filter($values);
+$values = array_filter($values, fn($value): bool => $value !== null && $value !== '');
$ok = FreshRSS_user_Controller::updateUser(
$username,
diff --git a/composer.json b/composer.json
index d2ae986ca..13344713d 100644
--- a/composer.json
+++ b/composer.json
@@ -77,8 +77,7 @@
"@phtml-lint",
"@phpunit",
"@phpcs",
- "@phpstan",
- "@phpstan-next"
+ "@phpstan"
],
"fix": [
"@translations",
diff --git a/lib/Minz/Migrator.php b/lib/Minz/Migrator.php
index 47df98e7f..c7e8ea15d 100644
--- a/lib/Minz/Migrator.php
+++ b/lib/Minz/Migrator.php
@@ -33,7 +33,7 @@ class Minz_Migrator
if ($applied_migrations === false) {
return "Cannot open the {$applied_migrations_path} file";
}
- $applied_migrations = array_filter(explode("\n", $applied_migrations));
+ $applied_migrations = array_filter(explode("\n", $applied_migrations), fn(string $migration): bool => trim($migration) !== '');
$migration_files = scandir($migrations_path) ?: [];
$migration_files = array_filter($migration_files, static function (string $filename) {
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 8954f9921..480152400 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -231,8 +231,8 @@ function format_bytes(int $bytes, int $precision = 2, string $system = 'IEC'): s
return format_number($bytes, $precision);
}
$bytes = max(intval($bytes), 0);
- $pow = $bytes === 0 ? 0 : floor(log($bytes) / log($base));
- $pow = min($pow, count($units) - 1);
+ $pow = $bytes === 0 ? 0 : (int)floor(log($bytes) / log($base));
+ $pow = min(max(0, $pow), count($units) - 1);
$bytes /= pow($base, $pow);
return format_number($bytes, $precision) . ' ' . $units[$pow];
}
diff --git a/phpstan-next.neon b/phpstan-next.neon
index ff29085b8..2b287e44c 100644
--- a/phpstan-next.neon
+++ b/phpstan-next.neon
@@ -4,19 +4,7 @@ includes:
parameters:
level: max
- strictRules:
- strictArrayFilter: true # TODO pass
+ reportPossiblyNonexistentGeneralArrayOffset: false # TODO: pass maybe
excludePaths:
analyse:
# TODO: Update files below and remove them from this list
- - app/Controllers/configureController.php
- - app/Controllers/feedController.php
- - app/Controllers/subscriptionController.php
- - app/Models/Entry.php
- - app/Models/UserQuery.php
- - cli/CliOption.php
- - cli/CliOptionsParser.php
- - cli/create-user.php
- - cli/reconfigure.php
- - cli/update-user.php
- - lib/Minz/Migrator.php
diff --git a/phpstan.dist.neon b/phpstan.dist.neon
index 4235be800..4cde7f8ab 100644
--- a/phpstan.dist.neon
+++ b/phpstan.dist.neon
@@ -41,15 +41,16 @@ parameters:
checkMissingOverrideMethodAttribute: true
checkTooWideReturnTypesInProtectedAndPublicMethods: true
reportAnyTypeWideningInVarTag: true
+ reportPossiblyNonexistentConstantArrayOffset: true
treatPhpDocTypesAsCertain: false
strictRules:
disallowedEmpty: false
disallowedLooseComparison: false
disallowedShortTernary: false
- strictArrayFilter: false # TODO pass
+ strictArrayFilter: true
exceptions:
check:
- missingCheckedExceptionInThrows: false # TODO pass
+ missingCheckedExceptionInThrows: false # TODO pass maybe
tooWideThrowType: true
implicitThrows: false
checkedExceptionClasses: