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

@ -24,7 +24,7 @@ class ApplicationUtils
* *
* @return mixed the version code from the repository if available, else 'false' * @return mixed the version code from the repository if available, else 'false'
*/ */
public static function getLatestGitVersionCode($url, $timeout=2) public static function getLatestGitVersionCode($url, $timeout = 2)
{ {
list($headers, $data) = get_http_response($url, $timeout); list($headers, $data) = get_http_response($url, $timeout);
@ -86,13 +86,14 @@ public static function getVersion($remote, $timeout = 2)
* *
* @return mixed the new version code if available and greater, else 'false' * @return mixed the new version code if available and greater, else 'false'
*/ */
public static function checkUpdate($currentVersion, public static function checkUpdate(
$updateFile, $currentVersion,
$checkInterval, $updateFile,
$enableCheck, $checkInterval,
$isLoggedIn, $enableCheck,
$branch='stable') $isLoggedIn,
{ $branch = 'stable'
) {
// Do not check versions for visitors // Do not check versions for visitors
// Do not check if the user doesn't want to // Do not check if the user doesn't want to
// Do not check with dev version // Do not check with dev version

View file

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

View file

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

View file

@ -64,29 +64,30 @@ function get_http_response($url, $timeout = 30, $maxBytes = 4194304, $curlWriteF
} }
// General cURL settings // General cURL settings
curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt( curl_setopt(
$ch, $ch,
CURLOPT_HTTPHEADER, CURLOPT_HTTPHEADER,
array('Accept-Language: ' . $acceptLanguage) array('Accept-Language: ' . $acceptLanguage)
); );
curl_setopt($ch, CURLOPT_MAXREDIRS, $maxRedirs); curl_setopt($ch, CURLOPT_MAXREDIRS, $maxRedirs);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
if (is_callable($curlWriteFunction)) { if (is_callable($curlWriteFunction)) {
curl_setopt($ch, CURLOPT_WRITEFUNCTION, $curlWriteFunction); curl_setopt($ch, CURLOPT_WRITEFUNCTION, $curlWriteFunction);
} }
// Max download size management // Max download size management
curl_setopt($ch, CURLOPT_BUFFERSIZE, 1024*16); curl_setopt($ch, CURLOPT_BUFFERSIZE, 1024*16);
curl_setopt($ch, CURLOPT_NOPROGRESS, false); curl_setopt($ch, CURLOPT_NOPROGRESS, false);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, curl_setopt(
function($arg0, $arg1, $arg2, $arg3, $arg4 = 0) use ($maxBytes) $ch,
{ CURLOPT_PROGRESSFUNCTION,
function ($arg0, $arg1, $arg2, $arg3, $arg4 = 0) use ($maxBytes) {
if (version_compare(phpversion(), '5.5', '<')) { if (version_compare(phpversion(), '5.5', '<')) {
// PHP version lower than 5.5 // PHP version lower than 5.5
// Callback has 4 arguments // Callback has 4 arguments
@ -232,7 +233,6 @@ function get_redirected_headers($url, $redirectionLimit = 3)
&& !empty($headers) && !empty($headers)
&& (strpos($headers[0], '301') !== false || strpos($headers[0], '302') !== false) && (strpos($headers[0], '301') !== false || strpos($headers[0], '302') !== false)
&& !empty($headers['Location'])) { && !empty($headers['Location'])) {
$redirection = is_array($headers['Location']) ? end($headers['Location']) : $headers['Location']; $redirection = is_array($headers['Location']) ? end($headers['Location']) : $headers['Location'];
if ($redirection != $url) { if ($redirection != $url) {
$redirection = getAbsoluteUrl($url, $redirection); $redirection = getAbsoluteUrl($url, $redirection);

View file

@ -92,7 +92,7 @@ public function __construct($language, $conf)
/** /**
* Initialize the translator using php gettext extension (gettext dependency act as a wrapper). * Initialize the translator using php gettext extension (gettext dependency act as a wrapper).
*/ */
protected function initGettextTranslator () protected function initGettextTranslator()
{ {
$this->translator = new GettextTranslator(); $this->translator = new GettextTranslator();
$this->translator->setLanguage($this->language); $this->translator->setLanguage($this->language);
@ -125,7 +125,8 @@ protected function initPhpTranslator()
$translations = $translations->addFromPoFile('inc/languages/'. $this->language .'/LC_MESSAGES/shaarli.po'); $translations = $translations->addFromPoFile('inc/languages/'. $this->language .'/LC_MESSAGES/shaarli.po');
$translations->setDomain('shaarli'); $translations->setDomain('shaarli');
$this->translator->loadTranslations($translations); $this->translator->loadTranslations($translations);
} catch (\InvalidArgumentException $e) {} } catch (\InvalidArgumentException $e) {
}
// Default extension translation from the current theme // Default extension translation from the current theme
$theme = $this->conf->get('theme'); $theme = $this->conf->get('theme');
@ -137,7 +138,8 @@ protected function initPhpTranslator()
); );
$translations->setDomain($theme); $translations->setDomain($theme);
$this->translator->loadTranslations($translations); $this->translator->loadTranslations($translations);
} catch (\InvalidArgumentException $e) {} } catch (\InvalidArgumentException $e) {
}
} }
// Extension translations (plugins, themes, etc.). // Extension translations (plugins, themes, etc.).
@ -150,7 +152,8 @@ protected function initPhpTranslator()
$extension = Translations::fromPoFile($translationPath . $this->language .'/LC_MESSAGES/'. $domain .'.po'); $extension = Translations::fromPoFile($translationPath . $this->language .'/LC_MESSAGES/'. $domain .'.po');
$extension->setDomain($domain); $extension->setDomain($domain);
$this->translator->loadTranslations($extension); $this->translator->loadTranslations($extension);
} catch (\InvalidArgumentException $e) {} } catch (\InvalidArgumentException $e) {
}
} }
} }

View file

@ -107,8 +107,7 @@ public function __construct(
$hidePublicLinks, $hidePublicLinks,
$redirector = '', $redirector = '',
$redirectorEncode = true $redirectorEncode = true
) ) {
{
$this->datastore = $datastore; $this->datastore = $datastore;
$this->loggedIn = $isLoggedIn; $this->loggedIn = $isLoggedIn;
$this->hidePublicLinks = $hidePublicLinks; $this->hidePublicLinks = $hidePublicLinks;
@ -317,8 +316,7 @@ private function read()
} else { } else {
$link['real_url'] .= $link['url']; $link['real_url'] .= $link['url'];
} }
} } else {
else {
$link['real_url'] = $link['url']; $link['real_url'] = $link['url'];
} }
@ -403,7 +401,8 @@ public function filterHash($request)
* *
* @return array list of shaare found. * @return array list of shaare found.
*/ */
public function filterDay($request) { public function filterDay($request)
{
$linkFilter = new LinkFilter($this->links); $linkFilter = new LinkFilter($this->links);
return $linkFilter->filter(LinkFilter::$FILTER_DAY, $request); return $linkFilter->filter(LinkFilter::$FILTER_DAY, $request);
} }
@ -492,8 +491,7 @@ public function renameTag($from, $to)
$delete = empty($to); $delete = empty($to);
// True for case-sensitive tag search. // True for case-sensitive tag search.
$linksToAlter = $this->filterSearch(['searchtags' => $from], true); $linksToAlter = $this->filterSearch(['searchtags' => $from], true);
foreach($linksToAlter as $key => &$value) foreach ($linksToAlter as $key => &$value) {
{
$tags = preg_split('/\s+/', trim($value['tags'])); $tags = preg_split('/\s+/', trim($value['tags']));
if (($pos = array_search($from, $tags)) !== false) { if (($pos = array_search($from, $tags)) !== false) {
if ($delete) { if ($delete) {
@ -536,7 +534,7 @@ public function reorder($order = 'DESC')
{ {
$order = $order === 'ASC' ? -1 : 1; $order = $order === 'ASC' ? -1 : 1;
// Reorder array by dates. // Reorder array by dates.
usort($this->links, function($a, $b) use ($order) { usort($this->links, function ($a, $b) use ($order) {
if (isset($a['sticky']) && isset($b['sticky']) && $a['sticky'] !== $b['sticky']) { if (isset($a['sticky']) && isset($b['sticky']) && $a['sticky'] !== $b['sticky']) {
return $a['sticky'] ? -1 : 1; return $a['sticky'] ? -1 : 1;
} }

View file

@ -62,7 +62,7 @@ public function filter($type, $request, $casesensitive = false, $visibility = 'a
$visibility = 'all'; $visibility = 'all';
} }
switch($type) { switch ($type) {
case self::$FILTER_HASH: case self::$FILTER_HASH:
return $this->filterSmallHash($request); return $this->filterSmallHash($request);
case self::$FILTER_TAG | self::$FILTER_TEXT: // == "vuotext" case self::$FILTER_TAG | self::$FILTER_TEXT: // == "vuotext"
@ -205,7 +205,6 @@ private function filterFulltext($searchterms, $visibility = 'all')
// Iterate over every stored link. // Iterate over every stored link.
foreach ($this->links as $id => $link) { foreach ($this->links as $id => $link) {
// ignore non private links when 'privatonly' is on. // ignore non private links when 'privatonly' is on.
if ($visibility !== 'all') { if ($visibility !== 'all') {
if (! $link['private'] && $visibility === 'private') { if (! $link['private'] && $visibility === 'private') {
@ -257,11 +256,11 @@ private function filterFulltext($searchterms, $visibility = 'all')
private static function tag2regex($tag) private static function tag2regex($tag)
{ {
$len = strlen($tag); $len = strlen($tag);
if(!$len || $tag === "-" || $tag === "*"){ if (!$len || $tag === "-" || $tag === "*") {
// nothing to search, return empty regex // nothing to search, return empty regex
return ''; return '';
} }
if($tag[0] === "-") { if ($tag[0] === "-") {
// query is negated // query is negated
$i = 1; // use offset to start after '-' character $i = 1; // use offset to start after '-' character
$regex = '(?!'; // create negative lookahead $regex = '(?!'; // create negative lookahead
@ -271,14 +270,14 @@ private static function tag2regex($tag)
} }
$regex .= '.*(?:^| )'; // before tag may only be a space or the beginning $regex .= '.*(?:^| )'; // before tag may only be a space or the beginning
// iterate over string, separating it into placeholder and content // iterate over string, separating it into placeholder and content
for(; $i < $len; $i++){ for (; $i < $len; $i++) {
if($tag[$i] === '*'){ if ($tag[$i] === '*') {
// placeholder found // placeholder found
$regex .= '[^ ]*?'; $regex .= '[^ ]*?';
} else { } else {
// regular characters // regular characters
$offset = strpos($tag, '*', $i); $offset = strpos($tag, '*', $i);
if($offset === false){ if ($offset === false) {
// no placeholder found, set offset to end of string // no placeholder found, set offset to end of string
$offset = $len; $offset = $len;
} }
@ -310,19 +309,19 @@ public function filterTags($tags, $casesensitive = false, $visibility = 'all')
{ {
// get single tags (we may get passed an array, even though the docs say different) // get single tags (we may get passed an array, even though the docs say different)
$inputTags = $tags; $inputTags = $tags;
if(!is_array($tags)) { if (!is_array($tags)) {
// we got an input string, split tags // we got an input string, split tags
$inputTags = preg_split('/(?:\s+)|,/', $inputTags, -1, PREG_SPLIT_NO_EMPTY); $inputTags = preg_split('/(?:\s+)|,/', $inputTags, -1, PREG_SPLIT_NO_EMPTY);
} }
if(!count($inputTags)){ if (!count($inputTags)) {
// no input tags // no input tags
return $this->noFilter($visibility); return $this->noFilter($visibility);
} }
// build regex from all tags // build regex from all tags
$re = '/^' . implode(array_map("self::tag2regex", $inputTags)) . '.*$/'; $re = '/^' . implode(array_map("self::tag2regex", $inputTags)) . '.*$/';
if(!$casesensitive) { if (!$casesensitive) {
// make regex case insensitive // make regex case insensitive
$re .= 'i'; $re .= 'i';
} }
@ -342,7 +341,7 @@ public function filterTags($tags, $casesensitive = false, $visibility = 'all')
} }
} }
$search = $link['tags']; // build search string, start with tags of current link $search = $link['tags']; // build search string, start with tags of current link
if(strlen(trim($link['description'])) && strpos($link['description'], '#') !== false){ if (strlen(trim($link['description'])) && strpos($link['description'], '#') !== false) {
// description given and at least one possible tag found // description given and at least one possible tag found
$descTags = array(); $descTags = array();
// find all tags in the form of #tag in the description // find all tags in the form of #tag in the description
@ -351,13 +350,13 @@ public function filterTags($tags, $casesensitive = false, $visibility = 'all')
$link['description'], $link['description'],
$descTags $descTags
); );
if(count($descTags[1])){ if (count($descTags[1])) {
// there were some tags in the description, add them to the search string // there were some tags in the description, add them to the search string
$search .= ' ' . implode(' ', $descTags[1]); $search .= ' ' . implode(' ', $descTags[1]);
} }
}; };
// match regular expression with search string // match regular expression with search string
if(!preg_match($re, $search)){ if (!preg_match($re, $search)) {
// this entry does _not_ match our regex // this entry does _not_ match our regex
continue; continue;
} }

View file

@ -23,7 +23,7 @@ function get_curl_download_callback(&$charset, &$title, $curlGetInfo = 'curl_get
* *
* @return int|bool length of $data or false if we need to stop the download * @return int|bool length of $data or false if we need to stop the download
*/ */
return function(&$ch, $data) use ($curlGetInfo, &$charset, &$title, &$isRedirected) { return function (&$ch, $data) use ($curlGetInfo, &$charset, &$title, &$isRedirected) {
$responseCode = $curlGetInfo($ch, CURLINFO_RESPONSE_CODE); $responseCode = $curlGetInfo($ch, CURLINFO_RESPONSE_CODE);
if (!empty($responseCode) && in_array($responseCode, [301, 302])) { if (!empty($responseCode) && in_array($responseCode, [301, 302])) {
$isRedirected = true; $isRedirected = true;
@ -201,7 +201,8 @@ function space2nbsp($text)
* @return string formatted description. * @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))); return nl2br(space2nbsp(hashtag_autolink(text2clickable($description, $redirector, $urlEncode), $indexUrl)));
} }

View file

@ -72,12 +72,11 @@ public static function filterAndFormat($linkDb, $selection, $prependNoteUrl, $in
private static function importStatus( private static function importStatus(
$filename, $filename,
$filesize, $filesize,
$importCount=0, $importCount = 0,
$overwriteCount=0, $overwriteCount = 0,
$skipCount=0, $skipCount = 0,
$duration=0 $duration = 0
) ) {
{
$status = sprintf(t('File %s (%d bytes) '), $filename, $filesize); $status = sprintf(t('File %s (%d bytes) '), $filename, $filesize);
if ($importCount == 0 && $overwriteCount == 0 && $skipCount == 0) { if ($importCount == 0 && $overwriteCount == 0 && $skipCount == 0) {
$status .= t('has an unknown file format. Nothing was imported.'); $status .= t('has an unknown file format. Nothing was imported.');

View file

@ -78,7 +78,6 @@ private function initialize()
); );
$this->tpl->assign('newVersion', escape($version)); $this->tpl->assign('newVersion', escape($version));
$this->tpl->assign('versionError', ''); $this->tpl->assign('versionError', '');
} catch (Exception $exc) { } catch (Exception $exc) {
logm($this->conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], $exc->getMessage()); logm($this->conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], $exc->getMessage());
$this->tpl->assign('newVersion', ''); $this->tpl->assign('newVersion', '');
@ -163,7 +162,7 @@ public function assignAll($data)
$this->initialize(); $this->initialize();
} }
if (empty($data) || !is_array($data)){ if (empty($data) || !is_array($data)) {
return false; return false;
} }

View file

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

View file

@ -183,7 +183,7 @@ public function updateMethodConfigToJson()
} }
} }
try{ try {
$this->conf->write($this->isLoggedIn); $this->conf->write($this->isLoggedIn);
return true; return true;
} catch (IOException $e) { } catch (IOException $e) {

View file

@ -34,8 +34,8 @@ function unparse_url($parsedUrl)
*/ */
function cleanup_url($url) function cleanup_url($url)
{ {
$obj_url = new Url($url); $obj_url = new Url($url);
return $obj_url->cleanup(); return $obj_url->cleanup();
} }
/** /**
@ -47,8 +47,8 @@ function cleanup_url($url)
*/ */
function get_url_scheme($url) function get_url_scheme($url)
{ {
$obj_url = new Url($url); $obj_url = new Url($url);
return $obj_url->getScheme(); return $obj_url->getScheme();
} }
/** /**
@ -217,7 +217,7 @@ protected function cleanupQuery()
} }
$this->parts['query'] = implode('&', $queryParams); $this->parts['query'] = implode('&', $queryParams);
} }
/** /**
* Removes undesired fragments * Removes undesired fragments
@ -269,7 +269,8 @@ public function idnToAscii()
* *
* @return string the URL scheme or false if none is provided. * @return string the URL scheme or false if none is provided.
*/ */
public function getScheme() { public function getScheme()
{
if (!isset($this->parts['scheme'])) { if (!isset($this->parts['scheme'])) {
return false; return false;
} }
@ -281,7 +282,8 @@ public function getScheme() {
* *
* @return string the URL host or false if none is provided. * @return string the URL host or false if none is provided.
*/ */
public function getHost() { public function getHost()
{
if (empty($this->parts['host'])) { if (empty($this->parts['host'])) {
return false; return false;
} }
@ -293,7 +295,8 @@ public function getHost() {
* *
* @return true is HTTP, false otherwise. * @return true is HTTP, false otherwise.
*/ */
public function isHttp() { public function isHttp()
{
return strpos(strtolower($this->parts['scheme']), 'http') !== false; return strpos(strtolower($this->parts['scheme']), 'http') !== false;
} }
} }

View file

@ -97,7 +97,7 @@ function escape($input)
if (is_array($input)) { if (is_array($input)) {
$out = array(); $out = array();
foreach($input as $key => $value) { foreach ($input as $key => $value) {
$out[$key] = escape($value); $out[$key] = escape($value);
} }
return $out; return $out;
@ -355,10 +355,13 @@ function return_bytes($val)
$val = trim($val); $val = trim($val);
$last = strtolower($val[strlen($val)-1]); $last = strtolower($val[strlen($val)-1]);
$val = intval(substr($val, 0, -1)); $val = intval(substr($val, 0, -1));
switch($last) { switch ($last) {
case 'g': $val *= 1024; case 'g':
case 'm': $val *= 1024; $val *= 1024;
case 'k': $val *= 1024; case 'm':
$val *= 1024;
case 'k':
$val *= 1024;
} }
return $val; return $val;
} }
@ -452,6 +455,7 @@ function alphabetical_sort(&$data, $reverse = false, $byKeys = false)
* *
* @return string Text translated. * @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); return dn__($domain, $text, $nText, $nb);
} }

View file

@ -65,7 +65,7 @@ public function __invoke($request, $response, $next)
try { try {
$this->checkRequest($request); $this->checkRequest($request);
$response = $next($request, $response); $response = $next($request, $response);
} catch(ApiException $e) { } catch (ApiException $e) {
$e->setResponse($response); $e->setResponse($response);
$e->setDebug($this->conf->get('dev.debug', false)); $e->setDebug($this->conf->get('dev.debug', false));
$response = $e->getApiResponse(); $response = $e->getApiResponse();
@ -98,7 +98,8 @@ protected function checkRequest($request)
* *
* @throws ApiAuthorizationException The token couldn't be validated. * @throws ApiAuthorizationException The token couldn't be validated.
*/ */
protected function checkToken($request) { protected function checkToken($request)
{
if (! $request->hasHeader('Authorization')) { if (! $request->hasHeader('Authorization')) {
throw new ApiAuthorizationException('JWT token not provided'); throw new ApiAuthorizationException('JWT token not provided');
} }

View file

@ -41,7 +41,7 @@ abstract class ApiController
/** /**
* ApiController constructor. * ApiController constructor.
* *
* Note: enabling debug mode displays JSON with readable formatting. * Note: enabling debug mode displays JSON with readable formatting.
* *
* @param Container $ci Slim container. * @param Container $ci Slim container.

View file

@ -35,8 +35,7 @@ public function getHistory($request, $response)
$offset = $request->getParam('offset'); $offset = $request->getParam('offset');
if (empty($offset)) { if (empty($offset)) {
$offset = 0; $offset = 0;
} } elseif (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');

View file

@ -7,7 +7,7 @@
/** /**
* Class Info * Class Info
* *
* REST API Controller: /info * REST API Controller: /info
* *
* @package Api\Controllers * @package Api\Controllers
@ -17,7 +17,7 @@ class Info extends ApiController
{ {
/** /**
* Service providing various information about Shaarli instance. * Service providing various information about Shaarli instance.
* *
* @param Request $request Slim request. * @param Request $request Slim request.
* @param Response $response Slim response. * @param Response $response Slim response.
* *

View file

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

View file

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

View file

@ -2,7 +2,6 @@
namespace Shaarli\Api\Exceptions; namespace Shaarli\Api\Exceptions;
use Slim\Http\Response; 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 there is no order, it means a disabled plugin has been enabled.
if (isset($formData['order_' . $key])) { if (isset($formData['order_' . $key])) {
$plugins[(int) $formData['order_' . $key]] = $key; $plugins[(int) $formData['order_' . $key]] = $key;
} } else {
else {
$newEnabledPlugins[] = $key; $newEnabledPlugins[] = $key;
} }
} }

View file

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