From 2c69095a1edf7474073451285238659d0f62ce3f Mon Sep 17 00:00:00 2001 From: Appleman1234 Date: Sun, 25 Sep 2022 13:30:13 +1000 Subject: PHP8.1 fixes from Rector --- tools/inc/lib/jsgettext/po2json.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'tools/inc/lib/jsgettext/po2json.php') diff --git a/tools/inc/lib/jsgettext/po2json.php b/tools/inc/lib/jsgettext/po2json.php index 847b0899..8fb6f69f 100644 --- a/tools/inc/lib/jsgettext/po2json.php +++ b/tools/inc/lib/jsgettext/po2json.php @@ -3,16 +3,12 @@ require_once 'PoeditParser.php'; function buildOptions($args) { - $options = array( - '-o' => null, - '-i' => null, - '-n' => 'l10n' - ); - $len = count($args); + $options = ['-o' => null, '-i' => null, '-n' => 'l10n']; + $len = is_countable($args) ? count($args) : 0; $i = 0; while ($i < $len) { - if (preg_match('#^-[a-z]$#i', $args[$i])) { - $options[$args[$i]] = isset($args[$i+1]) ? trim($args[$i+1]) : true; + if (preg_match('#^-[a-z]$#i', (string) $args[$i])) { + $options[$args[$i]] = isset($args[$i+1]) ? trim((string) $args[$i+1]) : true; $i += 2; } else { @@ -33,8 +29,8 @@ $poeditParser->parse(); if ($poeditParser->toJSON($options['-o'], $options['-n'])) { - $strings = count($poeditParser->getStrings()); - echo "Successfully exported " . count($strings) . " strings.\n"; + $strings = is_countable($poeditParser->getStrings()) ? count($poeditParser->getStrings()) : 0; + echo "Successfully exported " . (is_countable($strings) ? count($strings) : 0) . " strings.\n"; } else { echo "Cannor write to file '{$options['-o']}'.\n"; -- cgit v1.3