Fixed issues after running make code_sniffer

This commit is contained in:
Keith Carangelo 2021-09-08 15:46:51 -04:00
parent 6202038c65
commit c6f27b1ade

View file

@ -343,14 +343,14 @@ class BookmarkFilter
$re_and = implode(array_map([$this, 'tag2regex'], $inputTags));
$re = '/^' . $re_and;
$orTags = array_filter(array_map( function ($tag) {
return startsWith($tag, '~') ? substr( $tag, 1 ) : null;
}, $inputTags ));
$orTags = array_filter(array_map(function ($tag) {
return startsWith($tag, '~') ? substr($tag, 1) : null;
}, $inputTags));
$re_or = implode('|', array_map([$this, 'tag2match_term'], $orTags));
$re_or = implode('|', array_map([$this, 'tag2matchterm'], $orTags));
if ($re_or) {
$re_or = '(' . $re_or . ')';
$re .= $this->term2match( $re_or, false );
$re .= $this->term2match($re_or, false);
}
$re .= '.*$/';
@ -472,7 +472,9 @@ class BookmarkFilter
/**
* 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
*/
@ -485,26 +487,29 @@ class BookmarkFilter
}
$negate = false;
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] === "-") {
// 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;
}
$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
*
* @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
*/
protected function tag2match_term(string $tag): string
protected function tag2matchterm(string $tag): string
{
$tagsSeparator = $this->conf->get('general.tags_separator', ' ');
$len = strlen($tag);
@ -537,7 +542,7 @@ class BookmarkFilter
/**
* 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
*
* @return string generated regex fragment