Merge "MagicWord::replace*: Make sure we don't pass null into preg_match/preg_replace" into REL1_43
This commit is contained in:
commit
6beb3946d5
1 changed files with 5 additions and 5 deletions
|
|
@ -178,7 +178,7 @@ class MagicWord {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function match( $text ): bool {
|
public function match( $text ): bool {
|
||||||
return (bool)preg_match( $this->getRegex(), $text );
|
return (bool)preg_match( $this->getRegex(), $text ?? '' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -189,7 +189,7 @@ class MagicWord {
|
||||||
* @since 1.23
|
* @since 1.23
|
||||||
*/
|
*/
|
||||||
public function matchStartToEnd( $text ): bool {
|
public function matchStartToEnd( $text ): bool {
|
||||||
return (bool)preg_match( $this->getRegexStartToEnd(), $text );
|
return (bool)preg_match( $this->getRegexStartToEnd(), $text ?? '' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -203,7 +203,7 @@ class MagicWord {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function matchAndRemove( &$text ): bool {
|
public function matchAndRemove( &$text ): bool {
|
||||||
$text = preg_replace( $this->getRegex(), '', $text, -1, $count );
|
$text = preg_replace( $this->getRegex(), '', $text ?? '', -1, $count );
|
||||||
return (bool)$count;
|
return (bool)$count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,7 +212,7 @@ class MagicWord {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function matchStartAndRemove( &$text ): bool {
|
public function matchStartAndRemove( &$text ): bool {
|
||||||
$text = preg_replace( $this->getRegexStart(), '', $text, -1, $count );
|
$text = preg_replace( $this->getRegexStart(), '', $text ?? '', -1, $count );
|
||||||
return (bool)$count;
|
return (bool)$count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,7 +229,7 @@ class MagicWord {
|
||||||
$res = preg_replace(
|
$res = preg_replace(
|
||||||
$this->getRegex(),
|
$this->getRegex(),
|
||||||
StringUtils::escapeRegexReplacement( $replacement ),
|
StringUtils::escapeRegexReplacement( $replacement ),
|
||||||
$subject,
|
$subject ?? '',
|
||||||
$limit
|
$limit
|
||||||
);
|
);
|
||||||
return $res;
|
return $res;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue