From: ArthurHoaro Date: Wed, 28 Feb 2018 21:34:40 +0000 (+0100) Subject: PSR: use elseif instead of else if X-Git-Tag: v0.10.0~46^2 X-Git-Url: https://git.immae.eu/?p=github%2Fshaarli%2FShaarli.git;a=commitdiff_plain;h=d2d4f993e1e76bc68b65c48cb18476c404c97a41 PSR: use elseif instead of else if See https://www.php-fig.org/psr/psr-2/\#51-if-elseif-else --- diff --git a/application/FileUtils.php b/application/FileUtils.php index 918cb83b..b89ea12b 100644 --- a/application/FileUtils.php +++ b/application/FileUtils.php @@ -37,7 +37,7 @@ class FileUtils if (is_file($file) && !is_writeable($file)) { // The datastore exists but is not writeable throw new IOException($file); - } else if (!is_file($file) && !is_writeable(dirname($file))) { + } elseif (!is_file($file) && !is_writeable(dirname($file))) { // The datastore does not exist and its parent directory is not writeable throw new IOException(dirname($file)); } diff --git a/application/LinkFilter.php b/application/LinkFilter.php index 12376e27..e52239b8 100644 --- a/application/LinkFilter.php +++ b/application/LinkFilter.php @@ -117,7 +117,7 @@ class LinkFilter foreach ($this->links as $key => $value) { if ($value['private'] && $visibility === 'private') { $out[$key] = $value; - } else if (! $value['private'] && $visibility === 'public') { + } elseif (! $value['private'] && $visibility === 'public') { $out[$key] = $value; } } @@ -210,7 +210,7 @@ class LinkFilter if ($visibility !== 'all') { if (! $link['private'] && $visibility === 'private') { continue; - } else if ($link['private'] && $visibility === 'public') { + } elseif ($link['private'] && $visibility === 'public') { continue; } } @@ -337,7 +337,7 @@ class LinkFilter if ($visibility !== 'all') { if (! $link['private'] && $visibility === 'private') { continue; - } else if ($link['private'] && $visibility === 'public') { + } elseif ($link['private'] && $visibility === 'public') { continue; } } @@ -380,7 +380,7 @@ class LinkFilter if ($visibility !== 'all') { if (! $link['private'] && $visibility === 'private') { continue; - } else if ($link['private'] && $visibility === 'public') { + } elseif ($link['private'] && $visibility === 'public') { continue; } } diff --git a/application/NetscapeBookmarkUtils.php b/application/NetscapeBookmarkUtils.php index 2aa2da3b..b4d16d00 100644 --- a/application/NetscapeBookmarkUtils.php +++ b/application/NetscapeBookmarkUtils.php @@ -154,10 +154,10 @@ class NetscapeBookmarkUtils if (empty($post['privacy']) || $post['privacy'] == 'default') { // use value from the imported file $private = $bkm['pub'] == '1' ? 0 : 1; - } else if ($post['privacy'] == 'private') { + } elseif ($post['privacy'] == 'private') { // all imported links are private $private = 1; - } else if ($post['privacy'] == 'public') { + } elseif ($post['privacy'] == 'public') { // all imported links are public $private = 0; } diff --git a/application/Url.php b/application/Url.php index 21c17ecc..6b9870f0 100644 --- a/application/Url.php +++ b/application/Url.php @@ -81,7 +81,7 @@ function whitelist_protocols($url, $protocols) // Protocol not allowed: we remove it and replace it with http if ($protocol === 1 && ! in_array($match[1], $protocols)) { $url = str_replace($match[0], 'http://', $url); - } else if ($protocol !== 1) { + } elseif ($protocol !== 1) { $url = 'http://' . $url; } return $url; diff --git a/application/api/controllers/History.php b/application/api/controllers/History.php index 2ff9deaf..5cc453bf 100644 --- a/application/api/controllers/History.php +++ b/application/api/controllers/History.php @@ -36,7 +36,7 @@ class History extends ApiController if (empty($offset)) { $offset = 0; } - else if (ctype_digit($offset)) { + elseif (ctype_digit($offset)) { $offset = (int) $offset; } else { throw new ApiBadParametersException('Invalid offset'); @@ -46,7 +46,7 @@ class History extends ApiController $limit = $request->getParam('limit'); if (empty($limit)) { $limit = count($history); - } else if (ctype_digit($limit)) { + } elseif (ctype_digit($limit)) { $limit = (int) $limit; } else { throw new ApiBadParametersException('Invalid limit'); diff --git a/application/api/controllers/Links.php b/application/api/controllers/Links.php index eb78dd26..3a9c0355 100644 --- a/application/api/controllers/Links.php +++ b/application/api/controllers/Links.php @@ -59,9 +59,9 @@ class Links extends ApiController $limit = $request->getParam('limit'); if (empty($limit)) { $limit = self::$DEFAULT_LIMIT; - } else if (ctype_digit($limit)) { + } elseif (ctype_digit($limit)) { $limit = intval($limit); - } else if ($limit === 'all') { + } elseif ($limit === 'all') { $limit = count($links); } else { throw new ApiBadParametersException('Invalid limit'); diff --git a/index.php b/index.php index bd34c0cd..3b8b52a7 100644 --- a/index.php +++ b/index.php @@ -887,7 +887,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, if (empty($params['searchtags'])) { $params['searchtags'] = trim($_GET['addtag']); } - else if ($addtag) { + elseif ($addtag) { $params['searchtags'] = trim($params['searchtags']).' '.trim($_GET['addtag']); } @@ -953,7 +953,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, } else { unset($_SESSION['visibility']); } - } else if ($_GET['visibility'] === 'public') { + } elseif ($_GET['visibility'] === 'public') { if (empty($_SESSION['visibility']) || $_SESSION['visibility'] !== 'public') { // See only public links $_SESSION['visibility'] = 'public'; diff --git a/tests/plugins/test/test.php b/tests/plugins/test/test.php index 3d750c90..2aaf5122 100644 --- a/tests/plugins/test/test.php +++ b/tests/plugins/test/test.php @@ -11,7 +11,7 @@ function hook_test_random($data) { if (isset($data['_PAGE_']) && $data['_PAGE_'] == 'test') { $data[1] = 'page test'; - } else if (isset($data['_LOGGEDIN_']) && $data['_LOGGEDIN_'] === true) { + } elseif (isset($data['_LOGGEDIN_']) && $data['_LOGGEDIN_'] === true) { $data[1] = 'loggedin'; } else { $data[1] = $data[0];