From: Kunal Mehta Date: Thu, 29 Jan 2015 04:49:57 +0000 (-0800) Subject: replacers: Make Replacer abstract, and add abstract Replacer::replace() X-Git-Tag: 1.31.0-rc.0~12572 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=60a92d256a388801645c36860eaa18ea42eed1f4;p=lhc%2Fweb%2Fwiklou.git replacers: Make Replacer abstract, and add abstract Replacer::replace() Change-Id: Ib00dc8585e8ba599491e51e0b99a8667c3b4cd63 --- diff --git a/includes/libs/replacers/DoubleReplacer.php b/includes/libs/replacers/DoubleReplacer.php index 20a4089a6c..fed023b1ba 100644 --- a/includes/libs/replacers/DoubleReplacer.php +++ b/includes/libs/replacers/DoubleReplacer.php @@ -37,7 +37,7 @@ class DoubleReplacer extends Replacer { * @param array $matches * @return mixed */ - public function replace( $matches ) { + public function replace( array $matches ) { return str_replace( $this->from, $this->to, $matches[$this->index] ); } } diff --git a/includes/libs/replacers/HashtableReplacer.php b/includes/libs/replacers/HashtableReplacer.php index e1572f2b57..b3c219d40a 100644 --- a/includes/libs/replacers/HashtableReplacer.php +++ b/includes/libs/replacers/HashtableReplacer.php @@ -37,7 +37,7 @@ class HashtableReplacer extends Replacer { * @param array $matches * @return mixed */ - public function replace( $matches ) { + public function replace( array $matches ) { return $this->table[$matches[$this->index]]; } } diff --git a/includes/libs/replacers/RegexlikeReplacer.php b/includes/libs/replacers/RegexlikeReplacer.php index 630a754762..2b1fa74023 100644 --- a/includes/libs/replacers/RegexlikeReplacer.php +++ b/includes/libs/replacers/RegexlikeReplacer.php @@ -35,7 +35,7 @@ class RegexlikeReplacer extends Replacer { * @param array $matches * @return string */ - public function replace( $matches ) { + public function replace( array $matches ) { $pairs = array(); foreach ( $matches as $i => $match ) { $pairs["\$$i"] = $match; diff --git a/includes/libs/replacers/Replacer.php b/includes/libs/replacers/Replacer.php index 924fb30775..f4850bf6ad 100644 --- a/includes/libs/replacers/Replacer.php +++ b/includes/libs/replacers/Replacer.php @@ -22,11 +22,17 @@ * Base class for "replacers", objects used in preg_replace_callback() and * StringUtils::delimiterReplaceCallback() */ -class Replacer { +abstract class Replacer { /** * @return array */ public function cb() { return array( &$this, 'replace' ); } + + /** + * @param array $matches + * @return string + */ + abstract public function replace( array $matches ); }