X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flibs%2FReplacementArray.php;h=4512a4b13d933618a5c63d5044c8338b6cac03a3;hp=ea50a854b2eb8eed249697e77490a6ee9c8ffde0;hb=aec80a1fb774715e43430ab583c190b79e468fce;hpb=638c4528259b71a5bc90439fad7cd8d110a86b06 diff --git a/includes/libs/ReplacementArray.php b/includes/libs/ReplacementArray.php index ea50a854b2..4512a4b13d 100644 --- a/includes/libs/ReplacementArray.php +++ b/includes/libs/ReplacementArray.php @@ -19,19 +19,17 @@ */ /** - * Replacement array for FSS with fallback to strtr() - * Supports lazy initialisation of FSS resource + * Wrapper around strtr() that holds replacements */ class ReplacementArray { private $data = false; - private $fss = false; /** * Create an object with the specified replacement array * The array should have the same form as the replacement array for strtr() * @param array $data */ - public function __construct( $data = array() ) { + public function __construct( $data = [] ) { $this->data = $data; } @@ -39,11 +37,7 @@ class ReplacementArray { * @return array */ public function __sleep() { - return array( 'data' ); - } - - public function __wakeup() { - $this->fss = false; + return [ 'data' ]; } /** @@ -52,7 +46,6 @@ class ReplacementArray { */ public function setArray( $data ) { $this->data = $data; - $this->fss = false; } /** @@ -69,7 +62,6 @@ class ReplacementArray { */ public function setPair( $from, $to ) { $this->data[$from] = $to; - $this->fss = false; } /** @@ -77,7 +69,6 @@ class ReplacementArray { */ public function mergeArray( $data ) { $this->data = $data + $this->data; - $this->fss = false; } /** @@ -85,7 +76,6 @@ class ReplacementArray { */ public function merge( ReplacementArray $other ) { $this->data = $other->data + $this->data; - $this->fss = false; } /** @@ -93,7 +83,6 @@ class ReplacementArray { */ public function removePair( $from ) { unset( $this->data[$from] ); - $this->fss = false; } /** @@ -103,7 +92,6 @@ class ReplacementArray { foreach ( $data as $from => $to ) { $this->removePair( $from ); } - $this->fss = false; } /** @@ -111,18 +99,6 @@ class ReplacementArray { * @return string */ public function replace( $subject ) { - if ( - function_exists( 'fss_prep_replace' ) && - version_compare( PHP_VERSION, '5.5.0' ) < 0 - ) { - if ( $this->fss === false ) { - $this->fss = fss_prep_replace( $this->data ); - } - $result = fss_exec_replace( $this->fss, $subject ); - } else { - $result = strtr( $subject, $this->data ); - } - - return $result; + return strtr( $subject, $this->data ); } }