lint: apply phpcbf to application/

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
This commit is contained in:
VirtualTam 2018-10-13 00:19:03 +02:00
parent 04ec8fedd9
commit f211e417bf
23 changed files with 98 additions and 93 deletions

View File

@ -86,13 +86,14 @@ class ApplicationUtils
*
* @return mixed the new version code if available and greater, else 'false'
*/
public static function checkUpdate($currentVersion,
public static function checkUpdate(
$currentVersion,
$updateFile,
$checkInterval,
$enableCheck,
$isLoggedIn,
$branch='stable')
{
$branch = 'stable'
) {
// Do not check versions for visitors
// Do not check if the user doesn't want to
// Do not check with dev version

View File

@ -2,7 +2,6 @@
namespace Shaarli;
/**
* URL-safe Base64 operations
*
@ -17,7 +16,8 @@ class Base64Url
*
* @return string Base64Url-encoded data
*/
public static function encode($data) {
public static function encode($data)
{
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
@ -28,7 +28,8 @@ class Base64Url
*
* @return string Decoded data
*/
public static function decode($data) {
public static function decode($data)
{
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
}
}

View File

@ -163,7 +163,8 @@ class FeedBuilder
$upDate = $link['updated'];
$link['up_iso_date'] = $this->getIsoDate($upDate, DateTime::ATOM);
} else {
$link['up_iso_date'] = $this->getIsoDate($pubDate, DateTime::ATOM);;
$link['up_iso_date'] = $this->getIsoDate($pubDate, DateTime::ATOM);
;
}
// Save the more recent item.
@ -261,7 +262,6 @@ class FeedBuilder
}
if ($this->feedType == self::$FEED_RSS) {
return $date->format(DateTime::RSS);
}
return $date->format(DateTime::ATOM);
}

View File

@ -84,9 +84,10 @@ function get_http_response($url, $timeout = 30, $maxBytes = 4194304, $curlWriteF
// Max download size management
curl_setopt($ch, CURLOPT_BUFFERSIZE, 1024*16);
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION,
function($arg0, $arg1, $arg2, $arg3, $arg4 = 0) use ($maxBytes)
{
curl_setopt(
$ch,
CURLOPT_PROGRESSFUNCTION,
function ($arg0, $arg1, $arg2, $arg3, $arg4 = 0) use ($maxBytes) {
if (version_compare(phpversion(), '5.5', '<')) {
// PHP version lower than 5.5
// Callback has 4 arguments
@ -232,7 +233,6 @@ function get_redirected_headers($url, $redirectionLimit = 3)
&& !empty($headers)
&& (strpos($headers[0], '301') !== false || strpos($headers[0], '302') !== false)
&& !empty($headers['Location'])) {
$redirection = is_array($headers['Location']) ? end($headers['Location']) : $headers['Location'];
if ($redirection != $url) {
$redirection = getAbsoluteUrl($url, $redirection);

View File

@ -125,7 +125,8 @@ class Languages
$translations = $translations->addFromPoFile('inc/languages/'. $this->language .'/LC_MESSAGES/shaarli.po');
$translations->setDomain('shaarli');
$this->translator->loadTranslations($translations);
} catch (\InvalidArgumentException $e) {}
} catch (\InvalidArgumentException $e) {
}
// Default extension translation from the current theme
$theme = $this->conf->get('theme');
@ -137,7 +138,8 @@ class Languages
);
$translations->setDomain($theme);
$this->translator->loadTranslations($translations);
} catch (\InvalidArgumentException $e) {}
} catch (\InvalidArgumentException $e) {
}
}
// Extension translations (plugins, themes, etc.).
@ -150,7 +152,8 @@ class Languages
$extension = Translations::fromPoFile($translationPath . $this->language .'/LC_MESSAGES/'. $domain .'.po');
$extension->setDomain($domain);
$this->translator->loadTranslations($extension);
} catch (\InvalidArgumentException $e) {}
} catch (\InvalidArgumentException $e) {
}
}
}

View File

@ -107,8 +107,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess
$hidePublicLinks,
$redirector = '',
$redirectorEncode = true
)
{
) {
$this->datastore = $datastore;
$this->loggedIn = $isLoggedIn;
$this->hidePublicLinks = $hidePublicLinks;
@ -317,8 +316,7 @@ You use the community supported version of the original Shaarli project, by Seba
} else {
$link['real_url'] .= $link['url'];
}
}
else {
} else {
$link['real_url'] = $link['url'];
}
@ -403,7 +401,8 @@ You use the community supported version of the original Shaarli project, by Seba
*
* @return array list of shaare found.
*/
public function filterDay($request) {
public function filterDay($request)
{
$linkFilter = new LinkFilter($this->links);
return $linkFilter->filter(LinkFilter::$FILTER_DAY, $request);
}
@ -492,8 +491,7 @@ You use the community supported version of the original Shaarli project, by Seba
$delete = empty($to);
// True for case-sensitive tag search.
$linksToAlter = $this->filterSearch(['searchtags' => $from], true);
foreach($linksToAlter as $key => &$value)
{
foreach ($linksToAlter as $key => &$value) {
$tags = preg_split('/\s+/', trim($value['tags']));
if (($pos = array_search($from, $tags)) !== false) {
if ($delete) {

View File

@ -205,7 +205,6 @@ class LinkFilter
// Iterate over every stored link.
foreach ($this->links as $id => $link) {
// ignore non private links when 'privatonly' is on.
if ($visibility !== 'all') {
if (! $link['private'] && $visibility === 'private') {

View File

@ -201,7 +201,8 @@ function space2nbsp($text)
* @return string formatted description.
*/
function format_description($description, $redirector = '', $urlEncode = true, $indexUrl = '') {
function format_description($description, $redirector = '', $urlEncode = true, $indexUrl = '')
{
return nl2br(space2nbsp(hashtag_autolink(text2clickable($description, $redirector, $urlEncode), $indexUrl)));
}

View File

@ -76,8 +76,7 @@ class NetscapeBookmarkUtils
$overwriteCount = 0,
$skipCount = 0,
$duration = 0
)
{
) {
$status = sprintf(t('File %s (%d bytes) '), $filename, $filesize);
if ($importCount == 0 && $overwriteCount == 0 && $skipCount == 0) {
$status .= t('has an unknown file format. Nothing was imported.');

View File

@ -78,7 +78,6 @@ class PageBuilder
);
$this->tpl->assign('newVersion', escape($version));
$this->tpl->assign('versionError', '');
} catch (Exception $exc) {
logm($this->conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], $exc->getMessage());
$this->tpl->assign('newVersion', '');

View File

@ -75,8 +75,7 @@ class PluginManager
try {
$this->loadPlugin($dirs[$index], $plugin);
}
catch (PluginFileNotFoundException $e) {
} catch (PluginFileNotFoundException $e) {
error_log($e->getMessage());
}
}

View File

@ -269,7 +269,8 @@ class Url
*
* @return string the URL scheme or false if none is provided.
*/
public function getScheme() {
public function getScheme()
{
if (!isset($this->parts['scheme'])) {
return false;
}
@ -281,7 +282,8 @@ class Url
*
* @return string the URL host or false if none is provided.
*/
public function getHost() {
public function getHost()
{
if (empty($this->parts['host'])) {
return false;
}
@ -293,7 +295,8 @@ class Url
*
* @return true is HTTP, false otherwise.
*/
public function isHttp() {
public function isHttp()
{
return strpos(strtolower($this->parts['scheme']), 'http') !== false;
}
}

View File

@ -356,9 +356,12 @@ function return_bytes($val)
$last = strtolower($val[strlen($val)-1]);
$val = intval(substr($val, 0, -1));
switch ($last) {
case 'g': $val *= 1024;
case 'm': $val *= 1024;
case 'k': $val *= 1024;
case 'g':
$val *= 1024;
case 'm':
$val *= 1024;
case 'k':
$val *= 1024;
}
return $val;
}
@ -452,6 +455,7 @@ function alphabetical_sort(&$data, $reverse = false, $byKeys = false)
*
* @return string Text translated.
*/
function t($text, $nText = '', $nb = 1, $domain = 'shaarli') {
function t($text, $nText = '', $nb = 1, $domain = 'shaarli')
{
return dn__($domain, $text, $nText, $nb);
}

View File

@ -98,7 +98,8 @@ class ApiMiddleware
*
* @throws ApiAuthorizationException The token couldn't be validated.
*/
protected function checkToken($request) {
protected function checkToken($request)
{
if (! $request->hasHeader('Authorization')) {
throw new ApiAuthorizationException('JWT token not provided');
}

View File

@ -35,8 +35,7 @@ class History extends ApiController
$offset = $request->getParam('offset');
if (empty($offset)) {
$offset = 0;
}
elseif (ctype_digit($offset)) {
} elseif (ctype_digit($offset)) {
$offset = (int) $offset;
} else {
throw new ApiBadParametersException('Invalid offset');

View File

@ -10,7 +10,8 @@ use Slim\Http\Response;
* Parent Exception related to the API, able to generate a valid Response (ResponseInterface).
* Also can include various information in debug mode.
*/
abstract class ApiException extends \Exception {
abstract class ApiException extends \Exception
{
/**
* @var Response instance from Slim.
@ -27,7 +28,7 @@ abstract class ApiException extends \Exception {
*
* @return Response Final response to give.
*/
public abstract function getApiResponse();
abstract public function getApiResponse();
/**
* Creates ApiResponse body.
@ -36,7 +37,8 @@ abstract class ApiException extends \Exception {
*
* @return array|string response body
*/
protected function getApiResponseBody() {
protected function getApiResponseBody()
{
if ($this->debug !== true) {
return $this->getMessage();
}

View File

@ -2,7 +2,6 @@
namespace Shaarli\Api\Exceptions;
use Slim\Http\Response;
/**

View File

@ -2,7 +2,6 @@
namespace Shaarli\Api\Exceptions;
use Slim\Http\Response;
/**

View File

@ -34,8 +34,7 @@ function save_plugin_config($formData)
// If there is no order, it means a disabled plugin has been enabled.
if (isset($formData['order_' . $key])) {
$plugins[(int) $formData['order_' . $key]] = $key;
}
else {
} else {
$newEnabledPlugins[] = $key;
}
}

View File

@ -95,7 +95,6 @@ class LoginManager
// The user client has a valid stay-signed-in cookie
// Session information is updated with the current client information
$this->sessionManager->storeLoginInfo($clientIpId);
} elseif ($this->sessionManager->hasSessionExpired()
|| $this->sessionManager->hasClientIpChanged($clientIpId)
) {