summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-09-11 17:14:53 +0200
committerGravatar GitHub <noreply@github.com> 2024-09-11 17:14:53 +0200
commitdfac9f5813df7d4c7c812c381364c8898333f559 (patch)
tree978496d0a8d8b0d6b5dbe836c6829296133b337c /cli
parent31c8846791d4b5316fbc790202f79545c012f9c2 (diff)
PHPStan booleansInConditions (#6793)
* PHPStan booleansInConditions * Uniformisation
Diffstat (limited to 'cli')
-rw-r--r--cli/CliOptionsParser.php11
-rwxr-xr-xcli/create-user.php2
-rwxr-xr-xcli/update-user.php2
3 files changed, 8 insertions, 7 deletions
diff --git a/cli/CliOptionsParser.php b/cli/CliOptionsParser.php
index f0c6bf9a2..5a2d353db 100644
--- a/cli/CliOptionsParser.php
+++ b/cli/CliOptionsParser.php
@@ -11,6 +11,7 @@ abstract class CliOptionsParser {
public string $usage = '';
public function __construct() {
+ /** @var array<string> $argv */
global $argv;
$this->usage = $this->getUsageMessage($argv[0]);
@@ -82,7 +83,7 @@ abstract class CliOptionsParser {
foreach ($this->inputs as $name => $input) {
$values = $input['values'] ?? $input['defaultInput'] ?? null;
$types = $this->options[$name]->getTypes();
- if ($values) {
+ if (!empty($values)) {
$validValues = [];
$typedValues = [];
@@ -205,8 +206,8 @@ abstract class CliOptionsParser {
foreach ($this->options as $option) {
$long[] = $option->getLongAlias() . $getoptNotation[$option->getValueTaken()];
- $long[] = $option->getDeprecatedAlias() ? $option->getDeprecatedAlias() . $getoptNotation[$option->getValueTaken()] : '';
- $short .= $option->getShortAlias() ? $option->getShortAlias() . $getoptNotation[$option->getValueTaken()] : '';
+ $long[] = $option->getDeprecatedAlias() != null ? $option->getDeprecatedAlias() . $getoptNotation[$option->getValueTaken()] : '';
+ $short .= $option->getShortAlias() != null ? $option->getShortAlias() . $getoptNotation[$option->getValueTaken()] : '';
}
return [
@@ -220,7 +221,7 @@ abstract class CliOptionsParser {
$optional = [];
foreach ($this->options as $name => $option) {
- $shortAlias = $option->getShortAlias() ? '-' . $option->getShortAlias() . ' ' : '';
+ $shortAlias = $option->getShortAlias() != null ? '-' . $option->getShortAlias() . ' ' : '';
$longAlias = '--' . $option->getLongAlias() . ($option->getValueTaken() === 'required' ? '=<' . strtolower($name) . '>' : '');
if ($this->inputs[$name]['required']) {
$required[] = $shortAlias . $longAlias;
@@ -235,7 +236,7 @@ abstract class CliOptionsParser {
private function makeInputRegex(): string {
$shortWithValues = '';
foreach ($this->options as $option) {
- if (($option->getValueTaken() === 'required' || $option->getValueTaken() === 'optional') && $option->getShortAlias()) {
+ if (($option->getValueTaken() === 'required' || $option->getValueTaken() === 'optional') && $option->getShortAlias() != null) {
$shortWithValues .= $option->getShortAlias();
}
}
diff --git a/cli/create-user.php b/cli/create-user.php
index 1be604a42..ae560b49e 100755
--- a/cli/create-user.php
+++ b/cli/create-user.php
@@ -58,7 +58,7 @@ if (!empty($cliOptions->errors)) {
$username = $cliOptions->user;
-if (preg_grep("/^$username$/i", listUsers())) {
+if (!empty(preg_grep("/^$username$/i", listUsers()))) {
fail('FreshRSS warning: username already exists “' . $username . '”', EXIT_CODE_ALREADY_EXISTS);
}
diff --git a/cli/update-user.php b/cli/update-user.php
index ff0177997..553025d2b 100755
--- a/cli/update-user.php
+++ b/cli/update-user.php
@@ -80,7 +80,7 @@ if (!$ok) {
if (isset($cliOptions->apiPassword)) {
$error = FreshRSS_api_Controller::updatePassword($cliOptions->apiPassword);
- if ($error) {
+ if ($error !== false) {
fail($error);
}
}