From 30c7a61a9b410f023c56ef19b9389a61647d8768 Mon Sep 17 00:00:00 2001 From: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com> Date: Thu, 16 Nov 2023 22:43:00 +0100 Subject: Use strict_types (#5830) * Little's optimisations and booleans in conditions * Apply strict type * Apply strict type * Apply strict type * Fix multiple bugs with PHP 8.2 and 8.3 * Many declares missing, more errors fixed * Apply strict type * Another approach * Stronger typing for Minz_Session * Fix case of SQLite --------- Co-authored-by: Luc Co-authored-by: Alexandre Alapetite --- cli/_cli.php | 2 ++ cli/_update-or-create-user.php | 1 + cli/actualize-user.php | 1 + cli/check.translation.php | 2 +- cli/create-user.php | 2 ++ cli/db-optimize.php | 1 + cli/delete-user.php | 1 + cli/do-install.php | 1 + cli/export-opml-for-user.php | 1 + cli/export-sqlite-for-user.php | 1 + cli/export-zip-for-user.php | 1 + cli/i18n/I18nCompletionValidator.php | 1 + cli/i18n/I18nData.php | 1 + cli/i18n/I18nFile.php | 11 ++++++----- cli/i18n/I18nUsageValidator.php | 5 +++-- cli/i18n/I18nValidatorInterface.php | 1 + cli/i18n/I18nValue.php | 7 ++++++- cli/import-for-user.php | 1 + cli/import-sqlite-for-user.php | 1 + cli/list-users.php | 1 + cli/manipulate.translation.php | 2 +- cli/prepare.php | 1 + cli/reconfigure.php | 1 + cli/update-user.php | 2 ++ cli/user-info.php | 1 + 25 files changed, 40 insertions(+), 10 deletions(-) (limited to 'cli') 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 @@ 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 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 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 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 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 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 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 @@ >> $i18n + * @param array>> $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 $translation + * @param array $translation * @return array> */ 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 $translation + * @param array $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 @@ */ private array $code; - /** @var array> */ + /** @var array> */ private array $reference; private int $totalEntries = 0; private int $failedEntries = 0; private string $result = ''; /** - * @param array> $reference + * @param array> $reference * @param array $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 @@ __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 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 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