diff options
| author | 2024-06-05 22:04:06 +0200 | |
|---|---|---|
| committer | 2024-06-05 22:04:06 +0200 | |
| commit | f99c8d5f54c67e0abc3f3189b4f5e3e4571e114c (patch) | |
| tree | d7d74a628cd9614dd4093220139b6c073f3a5c54 /cli | |
| parent | 8fc8ac3aefca73a4cd509313a2f1ad73ef7f2e1a (diff) | |
Modernize code to php7.4 (#6043)
* Modernize code to php7.4
* Modernize code to php7.4
* Modernize code to php7.4
* Modernize code to php7.4
* Modernize code to php7.4
* Modernize code to php7.4
* Modernize code to php7.4
* Modernize code to php7.4
* Modernize code to php7.4
* Modernize code to php7.4
* Modernize code to php7.4
* Modernize code to php7.4
* Modernize code to php7.4
* Consistency
---------
Co-authored-by: Luc <sanchezluc+freshrss@gmail.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/CliOptionsParser.php | 4 | ||||
| -rwxr-xr-x | cli/export-opml-for-user.php | 2 | ||||
| -rw-r--r-- | cli/i18n/I18nData.php | 9 | ||||
| -rw-r--r-- | cli/i18n/I18nFile.php | 14 | ||||
| -rwxr-xr-x | cli/prepare.php | 29 |
5 files changed, 28 insertions, 30 deletions
diff --git a/cli/CliOptionsParser.php b/cli/CliOptionsParser.php index 1a0967b53..f75f6c19a 100644 --- a/cli/CliOptionsParser.php +++ b/cli/CliOptionsParser.php @@ -92,11 +92,11 @@ abstract class CliOptionsParser { break; case 'int': $validValues = array_filter($values, static fn($value) => ctype_digit($value)); - $typedValues = array_map(static fn($value) => (int) $value, $validValues); + $typedValues = array_map(static fn($value) => (int)$value, $validValues); break; case 'bool': $validValues = array_filter($values, static fn($value) => filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null); - $typedValues = array_map(static fn($value) => (bool) filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE), $validValues); + $typedValues = array_map(static fn($value) => (bool)filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE), $validValues); break; } diff --git a/cli/export-opml-for-user.php b/cli/export-opml-for-user.php index 4866a848f..b78aeff98 100755 --- a/cli/export-opml-for-user.php +++ b/cli/export-opml-for-user.php @@ -23,7 +23,7 @@ $username = cliInitUser($cliOptions->user); fwrite(STDERR, 'FreshRSS exporting OPML for user “' . $username . "”…\n"); $export_service = new FreshRSS_Export_Service($username); -list($filename, $content) = $export_service->generateOpml(); +[$filename, $content] = $export_service->generateOpml(); echo $content; invalidateHttpCache($username); diff --git a/cli/i18n/I18nData.php b/cli/i18n/I18nData.php index 3bdff9aea..4142c92d1 100644 --- a/cli/i18n/I18nData.php +++ b/cli/i18n/I18nData.php @@ -93,9 +93,8 @@ class I18nData { * @return array<string> */ private function getNonReferenceLanguages(): array { - return array_filter(array_keys($this->data), static function (string $value) { - return static::REFERENCE_LANGUAGE !== $value; - }); + return array_filter(array_keys($this->data), + static fn(string $value) => static::REFERENCE_LANGUAGE !== $value); } /** @@ -145,9 +144,7 @@ class I18nData { $keys = array_keys($this->data[static::REFERENCE_LANGUAGE][$this->getFilenamePrefix($key)]); $parent = $this->getParentKey($key); - return array_values(array_filter($keys, static function (string $element) use ($parent) { - return false !== strpos($element, $parent); - })); + return array_values(array_filter($keys, static fn(string $element) => false !== strpos($element, $parent))); } /** diff --git a/cli/i18n/I18nFile.php b/cli/i18n/I18nFile.php index 8932bff57..8085164c5 100644 --- a/cli/i18n/I18nFile.php +++ b/cli/i18n/I18nFile.php @@ -8,7 +8,7 @@ class I18nFile { * @return array<string,array<string,array<string,I18nValue>>> */ public function load(): array { - $i18n = array(); + $i18n = []; $dirs = new DirectoryIterator(I18N_PATH); foreach ($dirs as $dir) { if ($dir->isDot()) { @@ -86,7 +86,7 @@ class I18nFile { * @return array<string,I18nValue> */ private function flatten(array $translation, string $prefix = ''): array { - $a = array(); + $a = []; if ('' !== $prefix) { $prefix .= '.'; @@ -113,7 +113,7 @@ class I18nFile { * @return array<string,array<string,I18nValue>> */ private function unflatten(array $translation): array { - $a = array(); + $a = []; ksort($translation, SORT_NATURAL); foreach ($translation as $compoundKey => $value) { @@ -136,7 +136,7 @@ class I18nFile { */ private function format(array $translation): string { $translation = var_export($this->unflatten($translation), true); - $patterns = array( + $patterns = [ '/ -> todo\',/', '/ -> dirty\',/', '/ -> ignore\',/', @@ -144,8 +144,8 @@ class I18nFile { '/=>\s*array/', '/(\w) {2}/', '/ {2}/', - ); - $replacements = array( + ]; + $replacements = [ "',\t// TODO", // Double quoting is mandatory to have a tab instead of the \t string "',\t// DIRTY", // Double quoting is mandatory to have a tab instead of the \t string "',\t// IGNORE", // Double quoting is mandatory to have a tab instead of the \t string @@ -153,7 +153,7 @@ class I18nFile { '=> array', '$1 ', "\t", // Double quoting is mandatory to have a tab instead of the \t string - ); + ]; $translation = preg_replace($patterns, $replacements, $translation); return <<<OUTPUT diff --git a/cli/prepare.php b/cli/prepare.php index ef6ebcc65..e587c821a 100755 --- a/cli/prepare.php +++ b/cli/prepare.php @@ -3,7 +3,7 @@ declare(strict_types=1); require(__DIR__ . '/_cli.php'); -$dirs = array( +$dirs = [ '/', '/cache', '/extensions-data', @@ -15,7 +15,7 @@ $dirs = array( '/tokens', '/users', '/users/_', -); +]; $ok = true; @@ -24,18 +24,19 @@ foreach ($dirs as $dir) { $ok &= touch(DATA_PATH . $dir . '/index.html'); } -file_put_contents(DATA_PATH . '/.htaccess', -"# Apache 2.2\n" . -"<IfModule !mod_authz_core.c>\n" . -" Order Allow,Deny\n" . -" Deny from all\n" . -" Satisfy all\n" . -"</IfModule>\n" . -"\n" . -"# Apache 2.4\n" . -"<IfModule mod_authz_core.c>\n" . -" Require all denied\n" . -"</IfModule>\n" +file_put_contents(DATA_PATH . '/.htaccess', <<<'EOF' + # Apache 2.2 + <IfModule !mod_authz_core.c> + Order Allow,Deny + Deny from all + Satisfy all + </IfModule> + + # Apache 2.4 + <IfModule mod_authz_core.c> + Require all denied + </IfModule> + EOF ); accessRights(); |
