From d2d4f993e1e76bc68b65c48cb18476c404c97a41 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 28 Feb 2018 22:34:40 +0100 Subject: PSR: use elseif instead of else if See https://www.php-fig.org/psr/psr-2/\#51-if-elseif-else --- application/LinkFilter.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'application/LinkFilter.php') 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 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; } } -- cgit v1.2.3 From f211e417bf637b8a83988175c29ee072c69f7642 Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Sat, 13 Oct 2018 00:19:03 +0200 Subject: lint: apply phpcbf to application/ Signed-off-by: VirtualTam --- application/LinkFilter.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'application/LinkFilter.php') diff --git a/application/LinkFilter.php b/application/LinkFilter.php index e52239b8..8f147974 100644 --- a/application/LinkFilter.php +++ b/application/LinkFilter.php @@ -62,7 +62,7 @@ class LinkFilter $visibility = 'all'; } - switch($type) { + switch ($type) { case self::$FILTER_HASH: return $this->filterSmallHash($request); case self::$FILTER_TAG | self::$FILTER_TEXT: // == "vuotext" @@ -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') { @@ -257,11 +256,11 @@ class LinkFilter private static function tag2regex($tag) { $len = strlen($tag); - if(!$len || $tag === "-" || $tag === "*"){ + if (!$len || $tag === "-" || $tag === "*") { // nothing to search, return empty regex return ''; } - if($tag[0] === "-") { + if ($tag[0] === "-") { // query is negated $i = 1; // use offset to start after '-' character $regex = '(?!'; // create negative lookahead @@ -271,14 +270,14 @@ class LinkFilter } $regex .= '.*(?:^| )'; // before tag may only be a space or the beginning // iterate over string, separating it into placeholder and content - for(; $i < $len; $i++){ - if($tag[$i] === '*'){ + for (; $i < $len; $i++) { + if ($tag[$i] === '*') { // placeholder found $regex .= '[^ ]*?'; } else { // regular characters $offset = strpos($tag, '*', $i); - if($offset === false){ + if ($offset === false) { // no placeholder found, set offset to end of string $offset = $len; } @@ -310,19 +309,19 @@ class LinkFilter { // get single tags (we may get passed an array, even though the docs say different) $inputTags = $tags; - if(!is_array($tags)) { + if (!is_array($tags)) { // we got an input string, split tags $inputTags = preg_split('/(?:\s+)|,/', $inputTags, -1, PREG_SPLIT_NO_EMPTY); } - if(!count($inputTags)){ + if (!count($inputTags)) { // no input tags return $this->noFilter($visibility); } // build regex from all tags $re = '/^' . implode(array_map("self::tag2regex", $inputTags)) . '.*$/'; - if(!$casesensitive) { + if (!$casesensitive) { // make regex case insensitive $re .= 'i'; } @@ -342,7 +341,7 @@ class LinkFilter } } $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 $descTags = array(); // find all tags in the form of #tag in the description @@ -351,13 +350,13 @@ class LinkFilter $link['description'], $descTags ); - if(count($descTags[1])){ + if (count($descTags[1])) { // there were some tags in the description, add them to the search string $search .= ' ' . implode(' ', $descTags[1]); } }; // match regular expression with search string - if(!preg_match($re, $search)){ + if (!preg_match($re, $search)) { // this entry does _not_ match our regex continue; } -- cgit v1.2.3