Fix spacing after @param and friends in comments
[lhc/web/wiklou.git] / includes / MagicWord.php
index bf15bf3..e301cea 100644 (file)
@@ -65,6 +65,7 @@ class MagicWord {
        var $mId, $mSynonyms, $mCaseSensitive;
        var $mRegex = '';
        var $mRegexStart = '';
+       var $mRegexStartToEnd = '';
        var $mBaseRegex = '';
        var $mVariableRegex = '';
        var $mVariableStartToEndRegex = '';
@@ -339,6 +340,7 @@ class MagicWord {
                $case = $this->mCaseSensitive ? '' : 'iu';
                $this->mRegex = "/{$this->mBaseRegex}/{$case}";
                $this->mRegexStart = "/^(?:{$this->mBaseRegex})/{$case}";
+               $this->mRegexStartToEnd = "/^(?:{$this->mBaseRegex})$/{$case}";
                $this->mVariableRegex = str_replace( "\\$1", "(.*?)", $this->mRegex );
                $this->mVariableStartToEndRegex = str_replace( "\\$1", "(.*?)",
                        "/^(?:{$this->mBaseRegex})$/{$case}" );
@@ -405,6 +407,19 @@ class MagicWord {
                return $this->mRegexStart;
        }
 
+       /**
+        * Gets a regex matching the word from start to end of a string
+        *
+        * @return string
+        * @since 1.23
+        */
+       function getRegexStartToEnd() {
+               if ( $this->mRegexStartToEnd == '' ) {
+                       $this->initRegex();
+               }
+               return $this->mRegexStartToEnd;
+       }
+
        /**
         * regex without the slashes and what not
         *
@@ -439,6 +454,18 @@ class MagicWord {
                return (bool)preg_match( $this->getRegexStart(), $text );
        }
 
+       /**
+        * Returns true if the text matched the word
+        *
+        * @param $text string
+        *
+        * @return bool
+        * @since 1.23
+        */
+       function matchStartToEnd( $text ) {
+               return (bool)preg_match( $this->getRegexStartToEnd(), $text );
+       }
+
        /**
         * Returns NULL if there's no match, the value of $1 otherwise
         * The return code is the matched string, if there's no variable
@@ -485,7 +512,7 @@ class MagicWord {
        }
 
        /**
-        * @param  $text
+        * @param $text
         * @return bool
         */
        function matchStartAndRemove( &$text ) {