From ae9bd4f3f2179e6b3400b1cd64ddcceb92623d3d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 10 Aug 2022 15:02:36 +0200 Subject: [PATCH] Changes: - reformatted and documented private method - used [] instead of deprecated/discouraged array() --- src/Console/Extract.php | 21 ++++++++++++++++----- src/Content/Widget.php | 4 ++-- src/Network/Probe.php | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Console/Extract.php b/src/Console/Extract.php index 06015f6970..17d142039e 100644 --- a/src/Console/Extract.php +++ b/src/Console/Extract.php @@ -21,6 +21,9 @@ namespace Friendica\Console; +use \RecursiveDirectoryIterator; +use \RecursiveIteratorIterator; + /** * Extracts translation strings from the Friendica project's files to be exported * to Transifex for translation. @@ -120,10 +123,10 @@ HELP; $arr[] = $matchtkns[0]; - $s .= '$a->strings[' . $matchtkns[0] . "] = array(\n"; + $s .= '$a->strings[' . $matchtkns[0] . "] = [\n"; $s .= "\t0 => " . $matchtkns[0] . ",\n"; $s .= "\t1 => " . $matchtkns[1] . ",\n"; - $s .= ");\n"; + $s .= "];\n"; } } } @@ -141,9 +144,17 @@ HELP; return 0; } - private function globRecursive($path) { - $dir_iterator = new \RecursiveDirectoryIterator($path); - $iterator = new \RecursiveIteratorIterator($dir_iterator, \RecursiveIteratorIterator::SELF_FIRST); + /** + * Returns an array with found files and directories including their paths. + * + * @param string $path Base path to scan + * + * @return array A flat array with found files and directories + */ + private function globRecursive(string $path): array + { + $dir_iterator = new RecursiveDirectoryIterator($path); + $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST); $return = []; foreach ($iterator as $file) { diff --git a/src/Content/Widget.php b/src/Content/Widget.php index fba027680c..f1f62c33fc 100644 --- a/src/Content/Widget.php +++ b/src/Content/Widget.php @@ -268,7 +268,7 @@ class Widget $r = DBA::select('contact', ['network'], $condition, ['group_by' => ['network'], 'order' => ['network']]); - $nets = array(); + $nets = []; while ($rr = DBA::fetch($r)) { $nets[] = ['ref' => $rr['network'], 'name' => ContactSelector::networkToName($rr['network'])]; } @@ -334,7 +334,7 @@ class Widget return ''; } - $terms = array(); + $terms = []; foreach (Post\Category::getArray($uid, Post\Category::CATEGORY) as $savedFolderName) { $terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName]; } diff --git a/src/Network/Probe.php b/src/Network/Probe.php index c54ddc8e99..d5d87ebf95 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -1738,7 +1738,7 @@ class Probe // Resolve arbitrary relative path // Lifted from https://www.php.net/manual/en/function.realpath.php#84012 $parts = array_filter(explode('/', $path), 'strlen'); - $absolutes = array(); + $absolutes = []; foreach ($parts as $part) { if ('.' == $part) continue; if ('..' == $part) { -- 2.39.5