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:
ArthurHoaro 2018-02-28 22:34:40 +01:00
parent b70436373b
commit d2d4f993e1
8 changed files with 15 additions and 15 deletions

View file

@ -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));
}

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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');

View file

@ -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');

View file

@ -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';

View file

@ -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];