aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2018-02-28 22:34:40 +0100
committerArthurHoaro <arthur@hoa.ro>2018-02-28 22:34:40 +0100
commitd2d4f993e1e76bc68b65c48cb18476c404c97a41 (patch)
tree833cf0646e7e7c195a8da9d5fee2812cd06f8a6d
parentb70436373b488ce9cd8b0dc287d058b5ca206347 (diff)
downloadShaarli-d2d4f993e1e76bc68b65c48cb18476c404c97a41.tar.gz
Shaarli-d2d4f993e1e76bc68b65c48cb18476c404c97a41.tar.zst
Shaarli-d2d4f993e1e76bc68b65c48cb18476c404c97a41.zip
PSR: use elseif instead of else if
See https://www.php-fig.org/psr/psr-2/\#51-if-elseif-else
-rw-r--r--application/FileUtils.php2
-rw-r--r--application/LinkFilter.php8
-rw-r--r--application/NetscapeBookmarkUtils.php4
-rw-r--r--application/Url.php2
-rw-r--r--application/api/controllers/History.php4
-rw-r--r--application/api/controllers/Links.php4
-rw-r--r--index.php4
-rw-r--r--tests/plugins/test/test.php2
8 files changed, 15 insertions, 15 deletions
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
37 if (is_file($file) && !is_writeable($file)) { 37 if (is_file($file) && !is_writeable($file)) {
38 // The datastore exists but is not writeable 38 // The datastore exists but is not writeable
39 throw new IOException($file); 39 throw new IOException($file);
40 } else if (!is_file($file) && !is_writeable(dirname($file))) { 40 } elseif (!is_file($file) && !is_writeable(dirname($file))) {
41 // The datastore does not exist and its parent directory is not writeable 41 // The datastore does not exist and its parent directory is not writeable
42 throw new IOException(dirname($file)); 42 throw new IOException(dirname($file));
43 } 43 }
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
117 foreach ($this->links as $key => $value) { 117 foreach ($this->links as $key => $value) {
118 if ($value['private'] && $visibility === 'private') { 118 if ($value['private'] && $visibility === 'private') {
119 $out[$key] = $value; 119 $out[$key] = $value;
120 } else if (! $value['private'] && $visibility === 'public') { 120 } elseif (! $value['private'] && $visibility === 'public') {
121 $out[$key] = $value; 121 $out[$key] = $value;
122 } 122 }
123 } 123 }
@@ -210,7 +210,7 @@ class LinkFilter
210 if ($visibility !== 'all') { 210 if ($visibility !== 'all') {
211 if (! $link['private'] && $visibility === 'private') { 211 if (! $link['private'] && $visibility === 'private') {
212 continue; 212 continue;
213 } else if ($link['private'] && $visibility === 'public') { 213 } elseif ($link['private'] && $visibility === 'public') {
214 continue; 214 continue;
215 } 215 }
216 } 216 }
@@ -337,7 +337,7 @@ class LinkFilter
337 if ($visibility !== 'all') { 337 if ($visibility !== 'all') {
338 if (! $link['private'] && $visibility === 'private') { 338 if (! $link['private'] && $visibility === 'private') {
339 continue; 339 continue;
340 } else if ($link['private'] && $visibility === 'public') { 340 } elseif ($link['private'] && $visibility === 'public') {
341 continue; 341 continue;
342 } 342 }
343 } 343 }
@@ -380,7 +380,7 @@ class LinkFilter
380 if ($visibility !== 'all') { 380 if ($visibility !== 'all') {
381 if (! $link['private'] && $visibility === 'private') { 381 if (! $link['private'] && $visibility === 'private') {
382 continue; 382 continue;
383 } else if ($link['private'] && $visibility === 'public') { 383 } elseif ($link['private'] && $visibility === 'public') {
384 continue; 384 continue;
385 } 385 }
386 } 386 }
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
154 if (empty($post['privacy']) || $post['privacy'] == 'default') { 154 if (empty($post['privacy']) || $post['privacy'] == 'default') {
155 // use value from the imported file 155 // use value from the imported file
156 $private = $bkm['pub'] == '1' ? 0 : 1; 156 $private = $bkm['pub'] == '1' ? 0 : 1;
157 } else if ($post['privacy'] == 'private') { 157 } elseif ($post['privacy'] == 'private') {
158 // all imported links are private 158 // all imported links are private
159 $private = 1; 159 $private = 1;
160 } else if ($post['privacy'] == 'public') { 160 } elseif ($post['privacy'] == 'public') {
161 // all imported links are public 161 // all imported links are public
162 $private = 0; 162 $private = 0;
163 } 163 }
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)
81 // Protocol not allowed: we remove it and replace it with http 81 // Protocol not allowed: we remove it and replace it with http
82 if ($protocol === 1 && ! in_array($match[1], $protocols)) { 82 if ($protocol === 1 && ! in_array($match[1], $protocols)) {
83 $url = str_replace($match[0], 'http://', $url); 83 $url = str_replace($match[0], 'http://', $url);
84 } else if ($protocol !== 1) { 84 } elseif ($protocol !== 1) {
85 $url = 'http://' . $url; 85 $url = 'http://' . $url;
86 } 86 }
87 return $url; 87 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
36 if (empty($offset)) { 36 if (empty($offset)) {
37 $offset = 0; 37 $offset = 0;
38 } 38 }
39 else if (ctype_digit($offset)) { 39 elseif (ctype_digit($offset)) {
40 $offset = (int) $offset; 40 $offset = (int) $offset;
41 } else { 41 } else {
42 throw new ApiBadParametersException('Invalid offset'); 42 throw new ApiBadParametersException('Invalid offset');
@@ -46,7 +46,7 @@ class History extends ApiController
46 $limit = $request->getParam('limit'); 46 $limit = $request->getParam('limit');
47 if (empty($limit)) { 47 if (empty($limit)) {
48 $limit = count($history); 48 $limit = count($history);
49 } else if (ctype_digit($limit)) { 49 } elseif (ctype_digit($limit)) {
50 $limit = (int) $limit; 50 $limit = (int) $limit;
51 } else { 51 } else {
52 throw new ApiBadParametersException('Invalid limit'); 52 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
59 $limit = $request->getParam('limit'); 59 $limit = $request->getParam('limit');
60 if (empty($limit)) { 60 if (empty($limit)) {
61 $limit = self::$DEFAULT_LIMIT; 61 $limit = self::$DEFAULT_LIMIT;
62 } else if (ctype_digit($limit)) { 62 } elseif (ctype_digit($limit)) {
63 $limit = intval($limit); 63 $limit = intval($limit);
64 } else if ($limit === 'all') { 64 } elseif ($limit === 'all') {
65 $limit = count($links); 65 $limit = count($links);
66 } else { 66 } else {
67 throw new ApiBadParametersException('Invalid limit'); 67 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,
887 if (empty($params['searchtags'])) { 887 if (empty($params['searchtags'])) {
888 $params['searchtags'] = trim($_GET['addtag']); 888 $params['searchtags'] = trim($_GET['addtag']);
889 } 889 }
890 else if ($addtag) { 890 elseif ($addtag) {
891 $params['searchtags'] = trim($params['searchtags']).' '.trim($_GET['addtag']); 891 $params['searchtags'] = trim($params['searchtags']).' '.trim($_GET['addtag']);
892 } 892 }
893 893
@@ -953,7 +953,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
953 } else { 953 } else {
954 unset($_SESSION['visibility']); 954 unset($_SESSION['visibility']);
955 } 955 }
956 } else if ($_GET['visibility'] === 'public') { 956 } elseif ($_GET['visibility'] === 'public') {
957 if (empty($_SESSION['visibility']) || $_SESSION['visibility'] !== 'public') { 957 if (empty($_SESSION['visibility']) || $_SESSION['visibility'] !== 'public') {
958 // See only public links 958 // See only public links
959 $_SESSION['visibility'] = 'public'; 959 $_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)
11{ 11{
12 if (isset($data['_PAGE_']) && $data['_PAGE_'] == 'test') { 12 if (isset($data['_PAGE_']) && $data['_PAGE_'] == 'test') {
13 $data[1] = 'page test'; 13 $data[1] = 'page test';
14 } else if (isset($data['_LOGGEDIN_']) && $data['_LOGGEDIN_'] === true) { 14 } elseif (isset($data['_LOGGEDIN_']) && $data['_LOGGEDIN_'] === true) {
15 $data[1] = 'loggedin'; 15 $data[1] = 'loggedin';
16 } else { 16 } else {
17 $data[1] = $data[0]; 17 $data[1] = $data[0];