PSR: use elseif instead of else if
See https://www.php-fig.org/psr/psr-2/\#51-if-elseif-else
This commit is contained in:
parent
b70436373b
commit
d2d4f993e1
8 changed files with 15 additions and 15 deletions
|
@ -37,7 +37,7 @@ public static function writeFlatDB($file, $content)
|
||||||
if (is_file($file) && !is_writeable($file)) {
|
if (is_file($file) && !is_writeable($file)) {
|
||||||
// The datastore exists but is not writeable
|
// The datastore exists but is not writeable
|
||||||
throw new IOException($file);
|
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
|
// The datastore does not exist and its parent directory is not writeable
|
||||||
throw new IOException(dirname($file));
|
throw new IOException(dirname($file));
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ private function noFilter($visibility = 'all')
|
||||||
foreach ($this->links as $key => $value) {
|
foreach ($this->links as $key => $value) {
|
||||||
if ($value['private'] && $visibility === 'private') {
|
if ($value['private'] && $visibility === 'private') {
|
||||||
$out[$key] = $value;
|
$out[$key] = $value;
|
||||||
} else if (! $value['private'] && $visibility === 'public') {
|
} elseif (! $value['private'] && $visibility === 'public') {
|
||||||
$out[$key] = $value;
|
$out[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ private function filterFulltext($searchterms, $visibility = 'all')
|
||||||
if ($visibility !== 'all') {
|
if ($visibility !== 'all') {
|
||||||
if (! $link['private'] && $visibility === 'private') {
|
if (! $link['private'] && $visibility === 'private') {
|
||||||
continue;
|
continue;
|
||||||
} else if ($link['private'] && $visibility === 'public') {
|
} elseif ($link['private'] && $visibility === 'public') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ public function filterTags($tags, $casesensitive = false, $visibility = 'all')
|
||||||
if ($visibility !== 'all') {
|
if ($visibility !== 'all') {
|
||||||
if (! $link['private'] && $visibility === 'private') {
|
if (! $link['private'] && $visibility === 'private') {
|
||||||
continue;
|
continue;
|
||||||
} else if ($link['private'] && $visibility === 'public') {
|
} elseif ($link['private'] && $visibility === 'public') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -380,7 +380,7 @@ public function filterUntagged($visibility)
|
||||||
if ($visibility !== 'all') {
|
if ($visibility !== 'all') {
|
||||||
if (! $link['private'] && $visibility === 'private') {
|
if (! $link['private'] && $visibility === 'private') {
|
||||||
continue;
|
continue;
|
||||||
} else if ($link['private'] && $visibility === 'public') {
|
} elseif ($link['private'] && $visibility === 'public') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,10 +154,10 @@ public static function import($post, $files, $linkDb, $conf, $history)
|
||||||
if (empty($post['privacy']) || $post['privacy'] == 'default') {
|
if (empty($post['privacy']) || $post['privacy'] == 'default') {
|
||||||
// use value from the imported file
|
// use value from the imported file
|
||||||
$private = $bkm['pub'] == '1' ? 0 : 1;
|
$private = $bkm['pub'] == '1' ? 0 : 1;
|
||||||
} else if ($post['privacy'] == 'private') {
|
} elseif ($post['privacy'] == 'private') {
|
||||||
// all imported links are private
|
// all imported links are private
|
||||||
$private = 1;
|
$private = 1;
|
||||||
} else if ($post['privacy'] == 'public') {
|
} elseif ($post['privacy'] == 'public') {
|
||||||
// all imported links are public
|
// all imported links are public
|
||||||
$private = 0;
|
$private = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ function whitelist_protocols($url, $protocols)
|
||||||
// Protocol not allowed: we remove it and replace it with http
|
// Protocol not allowed: we remove it and replace it with http
|
||||||
if ($protocol === 1 && ! in_array($match[1], $protocols)) {
|
if ($protocol === 1 && ! in_array($match[1], $protocols)) {
|
||||||
$url = str_replace($match[0], 'http://', $url);
|
$url = str_replace($match[0], 'http://', $url);
|
||||||
} else if ($protocol !== 1) {
|
} elseif ($protocol !== 1) {
|
||||||
$url = 'http://' . $url;
|
$url = 'http://' . $url;
|
||||||
}
|
}
|
||||||
return $url;
|
return $url;
|
||||||
|
|
|
@ -36,7 +36,7 @@ public function getHistory($request, $response)
|
||||||
if (empty($offset)) {
|
if (empty($offset)) {
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
}
|
}
|
||||||
else if (ctype_digit($offset)) {
|
elseif (ctype_digit($offset)) {
|
||||||
$offset = (int) $offset;
|
$offset = (int) $offset;
|
||||||
} else {
|
} else {
|
||||||
throw new ApiBadParametersException('Invalid offset');
|
throw new ApiBadParametersException('Invalid offset');
|
||||||
|
@ -46,7 +46,7 @@ public function getHistory($request, $response)
|
||||||
$limit = $request->getParam('limit');
|
$limit = $request->getParam('limit');
|
||||||
if (empty($limit)) {
|
if (empty($limit)) {
|
||||||
$limit = count($history);
|
$limit = count($history);
|
||||||
} else if (ctype_digit($limit)) {
|
} elseif (ctype_digit($limit)) {
|
||||||
$limit = (int) $limit;
|
$limit = (int) $limit;
|
||||||
} else {
|
} else {
|
||||||
throw new ApiBadParametersException('Invalid limit');
|
throw new ApiBadParametersException('Invalid limit');
|
||||||
|
|
|
@ -59,9 +59,9 @@ public function getLinks($request, $response)
|
||||||
$limit = $request->getParam('limit');
|
$limit = $request->getParam('limit');
|
||||||
if (empty($limit)) {
|
if (empty($limit)) {
|
||||||
$limit = self::$DEFAULT_LIMIT;
|
$limit = self::$DEFAULT_LIMIT;
|
||||||
} else if (ctype_digit($limit)) {
|
} elseif (ctype_digit($limit)) {
|
||||||
$limit = intval($limit);
|
$limit = intval($limit);
|
||||||
} else if ($limit === 'all') {
|
} elseif ($limit === 'all') {
|
||||||
$limit = count($links);
|
$limit = count($links);
|
||||||
} else {
|
} else {
|
||||||
throw new ApiBadParametersException('Invalid limit');
|
throw new ApiBadParametersException('Invalid limit');
|
||||||
|
|
|
@ -887,7 +887,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
|
||||||
if (empty($params['searchtags'])) {
|
if (empty($params['searchtags'])) {
|
||||||
$params['searchtags'] = trim($_GET['addtag']);
|
$params['searchtags'] = trim($_GET['addtag']);
|
||||||
}
|
}
|
||||||
else if ($addtag) {
|
elseif ($addtag) {
|
||||||
$params['searchtags'] = trim($params['searchtags']).' '.trim($_GET['addtag']);
|
$params['searchtags'] = trim($params['searchtags']).' '.trim($_GET['addtag']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -953,7 +953,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
|
||||||
} else {
|
} else {
|
||||||
unset($_SESSION['visibility']);
|
unset($_SESSION['visibility']);
|
||||||
}
|
}
|
||||||
} else if ($_GET['visibility'] === 'public') {
|
} elseif ($_GET['visibility'] === 'public') {
|
||||||
if (empty($_SESSION['visibility']) || $_SESSION['visibility'] !== 'public') {
|
if (empty($_SESSION['visibility']) || $_SESSION['visibility'] !== 'public') {
|
||||||
// See only public links
|
// See only public links
|
||||||
$_SESSION['visibility'] = 'public';
|
$_SESSION['visibility'] = 'public';
|
||||||
|
|
|
@ -11,7 +11,7 @@ function hook_test_random($data)
|
||||||
{
|
{
|
||||||
if (isset($data['_PAGE_']) && $data['_PAGE_'] == 'test') {
|
if (isset($data['_PAGE_']) && $data['_PAGE_'] == 'test') {
|
||||||
$data[1] = 'page test';
|
$data[1] = 'page test';
|
||||||
} else if (isset($data['_LOGGEDIN_']) && $data['_LOGGEDIN_'] === true) {
|
} elseif (isset($data['_LOGGEDIN_']) && $data['_LOGGEDIN_'] === true) {
|
||||||
$data[1] = 'loggedin';
|
$data[1] = 'loggedin';
|
||||||
} else {
|
} else {
|
||||||
$data[1] = $data[0];
|
$data[1] = $data[0];
|
||||||
|
|
Loading…
Reference in a new issue