Fixed issues after running make code_sniffer
This commit is contained in:
parent
6202038c65
commit
c6f27b1ade
1 changed files with 18 additions and 13 deletions
|
@ -343,14 +343,14 @@ public function filterTags($tags, bool $casesensitive = false, string $visibilit
|
||||||
$re_and = implode(array_map([$this, 'tag2regex'], $inputTags));
|
$re_and = implode(array_map([$this, 'tag2regex'], $inputTags));
|
||||||
$re = '/^' . $re_and;
|
$re = '/^' . $re_and;
|
||||||
|
|
||||||
$orTags = array_filter(array_map( function ($tag) {
|
$orTags = array_filter(array_map(function ($tag) {
|
||||||
return startsWith($tag, '~') ? substr( $tag, 1 ) : null;
|
return startsWith($tag, '~') ? substr($tag, 1) : null;
|
||||||
}, $inputTags ));
|
}, $inputTags));
|
||||||
|
|
||||||
$re_or = implode('|', array_map([$this, 'tag2match_term'], $orTags));
|
$re_or = implode('|', array_map([$this, 'tag2matchterm'], $orTags));
|
||||||
if ($re_or) {
|
if ($re_or) {
|
||||||
$re_or = '(' . $re_or . ')';
|
$re_or = '(' . $re_or . ')';
|
||||||
$re .= $this->term2match( $re_or, false );
|
$re .= $this->term2match($re_or, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
$re .= '.*$/';
|
$re .= '.*$/';
|
||||||
|
@ -472,7 +472,9 @@ public static function tagsStrToArray(string $tags, bool $casesensitive): array
|
||||||
/**
|
/**
|
||||||
* generate a regex fragment out of a tag
|
* generate a regex fragment out of a tag
|
||||||
*
|
*
|
||||||
* @param string $tag to generate regexs from. may start with '-' to negate, contain '*' as wildcard. Tags starting with '~' are treated separately as an 'OR' clause.
|
* @param string $tag to generate regexs from. may start with '-'
|
||||||
|
* to negate, contain '*' as wildcard. Tags starting with '~' are
|
||||||
|
* treated separately as an 'OR' clause.
|
||||||
*
|
*
|
||||||
* @return string generated regex fragment
|
* @return string generated regex fragment
|
||||||
*/
|
*/
|
||||||
|
@ -485,26 +487,29 @@ protected function tag2regex(string $tag): string
|
||||||
}
|
}
|
||||||
$negate = false;
|
$negate = false;
|
||||||
if ($tag[0] === "+" && $tag[1]) {
|
if ($tag[0] === "+" && $tag[1]) {
|
||||||
$tag = substr( $tag, 1 ); // use offset to start after '+' character
|
$tag = substr($tag, 1); // use offset to start after '+' character
|
||||||
}
|
}
|
||||||
if ($tag[0] === "-") {
|
if ($tag[0] === "-") {
|
||||||
// query is negated
|
// query is negated
|
||||||
$tag = substr( $tag, 1 ); // use offset to start after '-' character
|
$tag = substr($tag, 1); // use offset to start after '-' character
|
||||||
$negate = true;
|
$negate = true;
|
||||||
}
|
}
|
||||||
$term = $this->tag2match_term( $tag );
|
$term = $this->tag2matchterm($tag);
|
||||||
|
|
||||||
return $this->term2match( $term, $negate );
|
return $this->term2match($term, $negate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate a regex match term fragment out of a tag
|
* generate a regex match term fragment out of a tag
|
||||||
*
|
*
|
||||||
* @param string $tag to to generate regexs from. This function assumes any leading flags ('-', '~') have been stripped. The wildcard flag '*' is expanded by this function and any other regex characters are escaped.
|
* @param string $tag to to generate regexs from. This function
|
||||||
|
* assumes any leading flags ('-', '~') have been stripped. The
|
||||||
|
* wildcard flag '*' is expanded by this function and any other
|
||||||
|
* regex characters are escaped.
|
||||||
*
|
*
|
||||||
* @return string generated regex match term fragment
|
* @return string generated regex match term fragment
|
||||||
*/
|
*/
|
||||||
protected function tag2match_term(string $tag): string
|
protected function tag2matchterm(string $tag): string
|
||||||
{
|
{
|
||||||
$tagsSeparator = $this->conf->get('general.tags_separator', ' ');
|
$tagsSeparator = $this->conf->get('general.tags_separator', ' ');
|
||||||
$len = strlen($tag);
|
$len = strlen($tag);
|
||||||
|
@ -537,7 +542,7 @@ protected function tag2match_term(string $tag): string
|
||||||
/**
|
/**
|
||||||
* generate a regex fragment out of a match term
|
* generate a regex fragment out of a match term
|
||||||
*
|
*
|
||||||
* @param string $term is the match term already generated by tag2match_term
|
* @param string $term is the match term already generated by tag2matchterm
|
||||||
* @param bool $negate if true create a negative lookahead
|
* @param bool $negate if true create a negative lookahead
|
||||||
*
|
*
|
||||||
* @return string generated regex fragment
|
* @return string generated regex fragment
|
||||||
|
|
Loading…
Reference in a new issue