diff --git a/composer.json b/composer.json index bc4806b1..96b098f0 100644 --- a/composer.json +++ b/composer.json @@ -113,7 +113,7 @@ ], "cs": "phpcs", "cs:fix": "phpcbf", - "stan": "phpstan analyse module/*/src/ module/*/config config docker/config data/migrations --level=7", + "stan": "phpstan analyse module/*/src module/*/config config docker/config data/migrations --level=7", "test": [ "@test:unit", "@test:db", diff --git a/module/CLI/src/Command/BaseCommand.php b/module/CLI/src/Command/BaseCommand.php index ef6b5435..fbee8681 100644 --- a/module/CLI/src/Command/BaseCommand.php +++ b/module/CLI/src/Command/BaseCommand.php @@ -12,40 +12,36 @@ use function Shlinkio\Shlink\Core\kebabCaseToCamelCase; use function sprintf; use function str_contains; +/** @deprecated */ abstract class BaseCommand extends Command { /** - * @param mixed|null $default + * @param string|string[]|bool|null $default */ protected function addOptionWithDeprecatedFallback( string $name, ?string $shortcut = null, ?int $mode = null, string $description = '', - $default = null, + bool|string|array|null $default = null, ): self { $this->addOption($name, $shortcut, $mode, $description, $default); if (str_contains($name, '-')) { $camelCaseName = kebabCaseToCamelCase($name); - $this->addOption($camelCaseName, null, $mode, sprintf('[DEPRECATED] Same as "%s".', $name), $default); + $this->addOption($camelCaseName, null, $mode, sprintf('[DEPRECATED] Alias for "%s".', $name), $default); } return $this; } - /** - * @return bool|string|string[]|null - */ - protected function getOptionWithDeprecatedFallback(InputInterface $input, string $name) + // @phpstan-ignore-next-line + protected function getOptionWithDeprecatedFallback(InputInterface $input, string $name) // phpcs:ignore { $rawInput = method_exists($input, '__toString') ? $input->__toString() : ''; $camelCaseName = kebabCaseToCamelCase($name); + $resolvedOptionName = str_contains($rawInput, $camelCaseName) ? $camelCaseName : $name; - if (str_contains($rawInput, $camelCaseName)) { - return $input->getOption($camelCaseName); - } - - return $input->getOption($name); + return $input->getOption($resolvedOptionName); } } diff --git a/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php b/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php index 07d66855..0c5ef184 100644 --- a/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php +++ b/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php @@ -42,10 +42,7 @@ class GeolocationDbUpdateFailedException extends RuntimeException implements Exc return $e; } - /** - * @param mixed $buildEpoch - */ - public static function withInvalidEpochInOldDb($buildEpoch): self + public static function withInvalidEpochInOldDb(mixed $buildEpoch): self { $e = new self(sprintf( 'Build epoch with value "%s" from existing geolocation database, could not be parsed to integer.',