diff options
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/_cli.php | 2 | ||||
| -rw-r--r-- | cli/_update-or-create-user.php | 1 | ||||
| -rwxr-xr-x | cli/actualize-user.php | 1 | ||||
| -rwxr-xr-x | cli/check.translation.php | 2 | ||||
| -rwxr-xr-x | cli/create-user.php | 2 | ||||
| -rwxr-xr-x | cli/db-optimize.php | 1 | ||||
| -rwxr-xr-x | cli/delete-user.php | 1 | ||||
| -rwxr-xr-x | cli/do-install.php | 1 | ||||
| -rwxr-xr-x | cli/export-opml-for-user.php | 1 | ||||
| -rwxr-xr-x | cli/export-sqlite-for-user.php | 1 | ||||
| -rwxr-xr-x | cli/export-zip-for-user.php | 1 | ||||
| -rw-r--r-- | cli/i18n/I18nCompletionValidator.php | 1 | ||||
| -rw-r--r-- | cli/i18n/I18nData.php | 1 | ||||
| -rw-r--r-- | cli/i18n/I18nFile.php | 11 | ||||
| -rw-r--r-- | cli/i18n/I18nUsageValidator.php | 5 | ||||
| -rw-r--r-- | cli/i18n/I18nValidatorInterface.php | 1 | ||||
| -rw-r--r-- | cli/i18n/I18nValue.php | 7 | ||||
| -rwxr-xr-x | cli/import-for-user.php | 1 | ||||
| -rwxr-xr-x | cli/import-sqlite-for-user.php | 1 | ||||
| -rwxr-xr-x | cli/list-users.php | 1 | ||||
| -rwxr-xr-x | cli/manipulate.translation.php | 2 | ||||
| -rwxr-xr-x | cli/prepare.php | 1 | ||||
| -rwxr-xr-x | cli/reconfigure.php | 1 | ||||
| -rwxr-xr-x | cli/update-user.php | 2 | ||||
| -rwxr-xr-x | cli/user-info.php | 1 |
25 files changed, 40 insertions, 10 deletions
diff --git a/cli/_cli.php b/cli/_cli.php index 9c62f3b4c..eb2152082 100644 --- a/cli/_cli.php +++ b/cli/_cli.php @@ -1,4 +1,6 @@ <?php +declare(strict_types=1); + if (php_sapi_name() !== 'cli') { die('FreshRSS error: This PHP script may only be invoked from command line!'); } diff --git a/cli/_update-or-create-user.php b/cli/_update-or-create-user.php index 73b627597..69e6ce589 100644 --- a/cli/_update-or-create-user.php +++ b/cli/_update-or-create-user.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); require(__DIR__ . '/_cli.php'); performRequirementCheck(FreshRSS_Context::$system_conf->db['type'] ?? ''); diff --git a/cli/actualize-user.php b/cli/actualize-user.php index b7bc9c2ad..9b144b7bb 100755 --- a/cli/actualize-user.php +++ b/cli/actualize-user.php @@ -1,5 +1,6 @@ #!/usr/bin/env php <?php +declare(strict_types=1); require(__DIR__ . '/_cli.php'); performRequirementCheck(FreshRSS_Context::$system_conf->db['type'] ?? ''); diff --git a/cli/check.translation.php b/cli/check.translation.php index 34b43244f..747a35be9 100755 --- a/cli/check.translation.php +++ b/cli/check.translation.php @@ -1,6 +1,6 @@ #!/usr/bin/env php <?php - +declare(strict_types=1); require_once __DIR__ . '/i18n/I18nCompletionValidator.php'; require_once __DIR__ . '/i18n/I18nData.php'; require_once __DIR__ . '/i18n/I18nFile.php'; diff --git a/cli/create-user.php b/cli/create-user.php index c6364371a..286befe85 100755 --- a/cli/create-user.php +++ b/cli/create-user.php @@ -1,5 +1,7 @@ #!/usr/bin/env php <?php +declare(strict_types=1); + $isUpdate = false; require(__DIR__ . '/_update-or-create-user.php'); diff --git a/cli/db-optimize.php b/cli/db-optimize.php index ba14d12ea..2561e7cb2 100755 --- a/cli/db-optimize.php +++ b/cli/db-optimize.php @@ -1,5 +1,6 @@ #!/usr/bin/env php <?php +declare(strict_types=1); require(__DIR__ . '/_cli.php'); performRequirementCheck(FreshRSS_Context::$system_conf->db['type'] ?? ''); diff --git a/cli/delete-user.php b/cli/delete-user.php index fbbb2eebb..2ad84b7dc 100755 --- a/cli/delete-user.php +++ b/cli/delete-user.php @@ -1,5 +1,6 @@ #!/usr/bin/env php <?php +declare(strict_types=1); require(__DIR__ . '/_cli.php'); performRequirementCheck(FreshRSS_Context::$system_conf->db['type'] ?? ''); diff --git a/cli/do-install.php b/cli/do-install.php index 58fcb2254..1b391a458 100755 --- a/cli/do-install.php +++ b/cli/do-install.php @@ -1,5 +1,6 @@ #!/usr/bin/env php <?php +declare(strict_types=1); require(__DIR__ . '/_cli.php'); if (file_exists(DATA_PATH . '/applied_migrations.txt')) { diff --git a/cli/export-opml-for-user.php b/cli/export-opml-for-user.php index 755cbe035..a28bddced 100755 --- a/cli/export-opml-for-user.php +++ b/cli/export-opml-for-user.php @@ -1,5 +1,6 @@ #!/usr/bin/env php <?php +declare(strict_types=1); require(__DIR__ . '/_cli.php'); performRequirementCheck(FreshRSS_Context::$system_conf->db['type'] ?? ''); diff --git a/cli/export-sqlite-for-user.php b/cli/export-sqlite-for-user.php index b4265d28a..e1dc83987 100755 --- a/cli/export-sqlite-for-user.php +++ b/cli/export-sqlite-for-user.php @@ -1,5 +1,6 @@ #!/usr/bin/env php <?php +declare(strict_types=1); require(__DIR__ . '/_cli.php'); performRequirementCheck(FreshRSS_Context::$system_conf->db['type'] ?? ''); diff --git a/cli/export-zip-for-user.php b/cli/export-zip-for-user.php index 90e4b87e1..dedcb6c11 100755 --- a/cli/export-zip-for-user.php +++ b/cli/export-zip-for-user.php @@ -1,5 +1,6 @@ #!/usr/bin/env php <?php +declare(strict_types=1); require(__DIR__ . '/_cli.php'); performRequirementCheck(FreshRSS_Context::$system_conf->db['type'] ?? ''); diff --git a/cli/i18n/I18nCompletionValidator.php b/cli/i18n/I18nCompletionValidator.php index 6240580c4..4a8e54759 100644 --- a/cli/i18n/I18nCompletionValidator.php +++ b/cli/i18n/I18nCompletionValidator.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); require_once __DIR__ . '/I18nValidatorInterface.php'; diff --git a/cli/i18n/I18nData.php b/cli/i18n/I18nData.php index 957ec2887..6e87e1d7e 100644 --- a/cli/i18n/I18nData.php +++ b/cli/i18n/I18nData.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class I18nData { diff --git a/cli/i18n/I18nFile.php b/cli/i18n/I18nFile.php index 5a0c74aaa..8932bff57 100644 --- a/cli/i18n/I18nFile.php +++ b/cli/i18n/I18nFile.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); require_once __DIR__ . '/I18nValue.php'; @@ -27,7 +28,7 @@ class I18nFile { } /** - * @param array<string,array<array<string>>> $i18n + * @param array<string,array<string,array<string,I18nValue>>> $i18n */ public function dump(array $i18n): void { foreach ($i18n as $language => $file) { @@ -65,7 +66,7 @@ class I18nFile { } catch (ParseError $ex) { if (defined('STDERR')) { fwrite(STDERR, "Error while processing: $filename\n"); - fwrite(STDERR, $ex); + fwrite(STDERR, $ex->getMessage()); } die(1); } @@ -108,7 +109,7 @@ class I18nFile { * The first key is dropped since it represents the filename and we have * no use of it. * - * @param array<string> $translation + * @param array<string,I18nValue> $translation * @return array<string,array<string,I18nValue>> */ private function unflatten(array $translation): array { @@ -118,7 +119,7 @@ class I18nFile { foreach ($translation as $compoundKey => $value) { $keys = explode('.', $compoundKey); array_shift($keys); - eval("\$a['" . implode("']['", $keys) . "'] = '" . addcslashes($value, "'") . "';"); + eval("\$a['" . implode("']['", $keys) . "'] = '" . addcslashes($value->__toString(), "'") . "';"); } return $a; @@ -131,7 +132,7 @@ class I18nFile { * translation file. The array is first converted to a string then some * formatting regexes are applied to match the original content. * - * @param array<string> $translation + * @param array<string,I18nValue> $translation */ private function format(array $translation): string { $translation = var_export($this->unflatten($translation), true); diff --git a/cli/i18n/I18nUsageValidator.php b/cli/i18n/I18nUsageValidator.php index 49cc266f9..1267cd66d 100644 --- a/cli/i18n/I18nUsageValidator.php +++ b/cli/i18n/I18nUsageValidator.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); require_once __DIR__ . '/I18nValidatorInterface.php'; @@ -6,14 +7,14 @@ class I18nUsageValidator implements I18nValidatorInterface { /** @var array<string> */ private array $code; - /** @var array<string,array<string,string>> */ + /** @var array<string,array<string,I18nValue>> */ private array $reference; private int $totalEntries = 0; private int $failedEntries = 0; private string $result = ''; /** - * @param array<string,array<string,string>> $reference + * @param array<string,array<string,I18nValue>> $reference * @param array<string> $code */ public function __construct(array $reference, array $code) { diff --git a/cli/i18n/I18nValidatorInterface.php b/cli/i18n/I18nValidatorInterface.php index e6f5f7cdd..9266489f6 100644 --- a/cli/i18n/I18nValidatorInterface.php +++ b/cli/i18n/I18nValidatorInterface.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); interface I18nValidatorInterface { diff --git a/cli/i18n/I18nValue.php b/cli/i18n/I18nValue.php index 4a1ddaeee..22317e1ae 100644 --- a/cli/i18n/I18nValue.php +++ b/cli/i18n/I18nValue.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class I18nValue { private const STATE_DIRTY = 'dirty'; @@ -13,7 +14,11 @@ class I18nValue { private string $value; private ?string $state = null; - public function __construct(string $data) { + /** @param I18nValue|string $data */ + public function __construct($data) { + if ($data instanceof I18nValue) { + $data = $data->__toString(); + } $data = explode(' -> ', $data); $this->value = array_shift($data); diff --git a/cli/import-for-user.php b/cli/import-for-user.php index 405843133..212be7653 100755 --- a/cli/import-for-user.php +++ b/cli/import-for-user.php @@ -1,5 +1,6 @@ #!/usr/bin/env php <?php +declare(strict_types=1); require(__DIR__ . '/_cli.php'); performRequirementCheck(FreshRSS_Context::$system_conf->db['type'] ?? ''); diff --git a/cli/import-sqlite-for-user.php b/cli/import-sqlite-for-user.php index 3d1fcc7bf..62a9d86c4 100755 --- a/cli/import-sqlite-for-user.php +++ b/cli/import-sqlite-for-user.php @@ -1,5 +1,6 @@ #!/usr/bin/env php <?php +declare(strict_types=1); require(__DIR__ . '/_cli.php'); performRequirementCheck(FreshRSS_Context::$system_conf->db['type'] ?? ''); diff --git a/cli/list-users.php b/cli/list-users.php index cfb76a22d..276239b25 100755 --- a/cli/list-users.php +++ b/cli/list-users.php @@ -1,5 +1,6 @@ #!/usr/bin/env php <?php +declare(strict_types=1); require(__DIR__ . '/_cli.php'); $users = listUsers(); diff --git a/cli/manipulate.translation.php b/cli/manipulate.translation.php index 4ef7101a3..611cdb0d5 100755 --- a/cli/manipulate.translation.php +++ b/cli/manipulate.translation.php @@ -1,6 +1,6 @@ #!/usr/bin/env php <?php - +declare(strict_types=1); require_once __DIR__ . '/i18n/I18nData.php'; require_once __DIR__ . '/i18n/I18nFile.php'; require_once __DIR__ . '/../constants.php'; diff --git a/cli/prepare.php b/cli/prepare.php index e04cf7e19..ef6ebcc65 100755 --- a/cli/prepare.php +++ b/cli/prepare.php @@ -1,5 +1,6 @@ #!/usr/bin/env php <?php +declare(strict_types=1); require(__DIR__ . '/_cli.php'); $dirs = array( diff --git a/cli/reconfigure.php b/cli/reconfigure.php index e6da4bddc..7d502a17a 100755 --- a/cli/reconfigure.php +++ b/cli/reconfigure.php @@ -1,5 +1,6 @@ #!/usr/bin/env php <?php +declare(strict_types=1); require(__DIR__ . '/_cli.php'); $params = array( diff --git a/cli/update-user.php b/cli/update-user.php index adfc1dbdc..634a716e7 100755 --- a/cli/update-user.php +++ b/cli/update-user.php @@ -1,5 +1,7 @@ #!/usr/bin/env php <?php +declare(strict_types=1); + $isUpdate = true; require(__DIR__ . '/_update-or-create-user.php'); diff --git a/cli/user-info.php b/cli/user-info.php index 525125758..f24f81078 100755 --- a/cli/user-info.php +++ b/cli/user-info.php @@ -1,5 +1,6 @@ #!/usr/bin/env php <?php +declare(strict_types=1); require(__DIR__ . '/_cli.php'); const DATA_FORMAT = "%-7s | %-20s | %-5s | %-7s | %-25s | %-15s | %-10s | %-10s | %-10s | %-10s | %-10s | %-10s | %-5s | %-10s\n"; |
