Code cleanup in cleanSig
authorRob Church <robchurch@users.mediawiki.org>
Fri, 13 Jan 2006 09:47:09 +0000 (09:47 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Fri, 13 Jan 2006 09:47:09 +0000 (09:47 +0000)
* Remove gratuitous whitespace and eliminate needless use of one-time variables
* Remove @static tag since it's not static-safe and isn't used like that any more

includes/Parser.php

index 8776b05..c9f3d21 100644 (file)
@@ -3262,33 +3262,18 @@ class Parser
        /**
         * Clean up signature text
         *
-        * 1) Force transclusions to be substituted
-        * 2) Strip ~~~, ~~~~ and ~~~~~ out of signatures
+        * 1) Strip ~~~, ~~~~ and ~~~~~ out of signatures
+        * 2) Substitute all transclusions
         *
-        * @static
         * @param string $text
-        * @return string Text
+        * @return string Signature text
         */
        function cleanSig( $text ) {
-       
-               $mw = MagicWord::get( MAG_SUBST );
-               $substre = $mw->getBaseRegex();
-               $subst = $mw->getSynonym( 0 );
-               $i = $mw->getRegexCase();
-
-               $text = preg_replace(
-                       "/
-                               \{\{
-                                       (?!
-                                               (?:
-                                                       $substre
-                                               )
-                                       )
-                       /x$i",
-                       '{{' . $subst,
-                       $text
-               );
-               
+               $substWord = MagicWord::get( MAG_SUBST );
+               $substRegex = '/\{\{(?!(?:' . $substWord->getBaseRegex() . '))/x' . $substWord->getRegexCase();
+               $substText = '{{' . $substWord->getSynonym( 0 );
+
+               $text = preg_replace( $substRegex, $substText, $text );
                $text = preg_replace( '/~{3,5}/', '', $text );
                $text = $this->replaceVariables( $text );