Merge "Adapt StringUtils::isUtf8 to the top of Unicode at U+10FFFF"
[lhc/web/wiklou.git] / includes / StringUtils.php
index fc3cfd5..9e21d03 100644 (file)
@@ -257,8 +257,8 @@ class StringUtils {
        /**
         * More or less "markup-safe" explode()
         * Ignores any instances of the separator inside <...>
-        * @param $separator String
-        * @param $text String
+        * @param string $separator
+        * @param string $text
         * @return array
         */
        static function explodeMarkup( $separator, $text ) {
@@ -284,8 +284,8 @@ class StringUtils {
         * Escape a string to make it suitable for inclusion in a preg_replace()
         * replacement parameter.
         *
-        * @param $string String
-        * @return String
+        * @param string $string
+        * @return string
         */
        static function escapeRegexReplacement( $string ) {
                $string = str_replace( '\\', '\\\\', $string );
@@ -296,8 +296,8 @@ class StringUtils {
        /**
         * Workalike for explode() with limited memory usage.
         * Returns an Iterator
-        * @param $separator
-        * @param $subject
+        * @param string $separator
+        * @param string $subject
         * @return ArrayIterator|ExplodeIterator
         */
        static function explode( $separator, $subject ) {
@@ -330,14 +330,14 @@ class RegexlikeReplacer extends Replacer {
        var $r;
 
        /**
-        * @param $r string
+        * @param string $r
         */
        function __construct( $r ) {
                $this->r = $r;
        }
 
        /**
-        * @param $matches array
+        * @param array $matches
         * @return string
         */
        function replace( $matches ) {
@@ -358,7 +358,7 @@ class DoubleReplacer extends Replacer {
        /**
         * @param $from
         * @param $to
-        * @param $index int
+        * @param int $index
         */
        function __construct( $from, $to, $index = 0 ) {
                $this->from = $from;
@@ -367,7 +367,7 @@ class DoubleReplacer extends Replacer {
        }
 
        /**
-        * @param $matches array
+        * @param array $matches
         * @return mixed
         */
        function replace( $matches ) {
@@ -383,7 +383,7 @@ class HashtableReplacer extends Replacer {
 
        /**
         * @param $table
-        * @param $index int
+        * @param int $index
         */
        function __construct( $table, $index = 0 ) {
                $this->table = $table;
@@ -391,7 +391,7 @@ class HashtableReplacer extends Replacer {
        }
 
        /**
-        * @param $matches array
+        * @param array $matches
         * @return mixed
         */
        function replace( $matches ) {
@@ -429,6 +429,7 @@ class ReplacementArray {
 
        /**
         * Set the whole replacement array at once
+        * @param array $data
         */
        function setArray( $data ) {
                $this->data = $data;
@@ -444,8 +445,8 @@ class ReplacementArray {
 
        /**
         * Set an element of the replacement array
-        * @param $from string
-        * @param $to string
+        * @param string $from
+        * @param string $to
         */
        function setPair( $from, $to ) {
                $this->data[$from] = $to;
@@ -453,7 +454,7 @@ class ReplacementArray {
        }
 
        /**
-        * @param $data array
+        * @param array $data
         */
        function mergeArray( $data ) {
                $this->data = array_merge( $this->data, $data );
@@ -461,7 +462,7 @@ class ReplacementArray {
        }
 
        /**
-        * @param $other
+        * @param ReplacementArray $other
         */
        function merge( $other ) {
                $this->data = array_merge( $this->data, $other->data );
@@ -469,7 +470,7 @@ class ReplacementArray {
        }
 
        /**
-        * @param $from string
+        * @param string $from
         */
        function removePair( $from ) {
                unset( $this->data[$from] );
@@ -477,7 +478,7 @@ class ReplacementArray {
        }
 
        /**
-        * @param $data array
+        * @param array $data
         */
        function removeArray( $data ) {
                foreach ( $data as $from => $to ) {
@@ -487,7 +488,7 @@ class ReplacementArray {
        }
 
        /**
-        * @param $subject string
+        * @param string $subject
         * @return string
         */
        function replace( $subject ) {
@@ -534,15 +535,15 @@ class ExplodeIterator implements Iterator {
 
        /**
         * Construct a DelimIterator
-        * @param $delim string
-        * @param $s string
+        * @param string $delim
+        * @param string $subject
         */
-       function __construct( $delim, $s ) {
-               $this->subject = $s;
+       function __construct( $delim, $subject ) {
+               $this->subject = $subject;
                $this->delim = $delim;
 
                // Micro-optimisation (theoretical)
-               $this->subjectLength = strlen( $s );
+               $this->subjectLength = strlen( $subject );
                $this->delimLength = strlen( $delim );
 
                $this->rewind();
@@ -570,6 +571,9 @@ class ExplodeIterator implements Iterator {
                return $this->current;
        }
 
+       /**
+        * @return int|bool Current position or boolean false if invalid
+        */
        function key() {
                return $this->curPos;
        }