]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/pomo/streams.php
WordPress 4.2
[autoinstalls/wordpress.git] / wp-includes / pomo / streams.php
index efaffa5ae93787ccda46d369465db0b063f735ff..8e50ab4eac57914bbe1f6aa6de9492f087ca100b 100644 (file)
@@ -3,22 +3,22 @@
  * Classes, which help reading streams of data from files.
  * Based on the classes from Danilo Segan <danilo@kvota.net>
  *
- * @version $Id: streams.php 597 2011-01-16 20:14:36Z nbachiyski $
+ * @version $Id: streams.php 718 2012-10-31 00:32:02Z nbachiyski $
  * @package pomo
  * @subpackage streams
  */
 
 if ( !class_exists( 'POMO_Reader' ) ):
 class POMO_Reader {
-       
+
        var $endian = 'little';
        var $_post = '';
-       
+
        function POMO_Reader() {
                $this->is_overloaded = ((ini_get("mbstring.func_overload") & 2) != 0) && function_exists('mb_substr');
                $this->_pos = 0;
        }
-       
+
        /**
         * Sets the endianness of the file.
         *
@@ -40,7 +40,7 @@ class POMO_Reader {
                        return false;
                $endian_letter = ('big' == $this->endian)? 'N' : 'V';
                $int = unpack($endian_letter, $bytes);
-               return array_shift($int);
+               return reset( $int );
        }
 
        /**
@@ -57,8 +57,13 @@ class POMO_Reader {
                $endian_letter = ('big' == $this->endian)? 'N' : 'V';
                return unpack($endian_letter.$count, $bytes);
        }
-       
-       
+
+       /**
+        * @param string $string
+        * @param int    $start
+        * @param int    $length
+        * @return string
+        */
        function substr($string, $start, $length) {
                if ($this->is_overloaded) {
                        return mb_substr($string, $start, $length, 'ascii');
@@ -66,7 +71,11 @@ class POMO_Reader {
                        return substr($string, $start, $length);
                }
        }
-       
+
+       /**
+        * @param string $string
+        * @return int
+        */
        function strlen($string) {
                if ($this->is_overloaded) {
                        return mb_strlen($string, 'ascii');
@@ -74,7 +83,12 @@ class POMO_Reader {
                        return strlen($string);
                }
        }
-       
+
+       /**
+        * @param string $string
+        * @param int    $chunk_size
+        * @return array
+        */
        function str_split($string, $chunk_size) {
                if (!function_exists('str_split')) {
                        $length = $this->strlen($string);
@@ -86,8 +100,8 @@ class POMO_Reader {
                        return str_split( $string, $chunk_size );
                }
        }
-       
-               
+
+
        function pos() {
                return $this->_pos;
        }
@@ -95,7 +109,7 @@ class POMO_Reader {
        function is_resource() {
                return true;
        }
-       
+
        function close() {
                return true;
        }
@@ -104,15 +118,26 @@ endif;
 
 if ( !class_exists( 'POMO_FileReader' ) ):
 class POMO_FileReader extends POMO_Reader {
+
+       /**
+        * @param string $filename
+        */
        function POMO_FileReader($filename) {
                parent::POMO_Reader();
                $this->_f = fopen($filename, 'rb');
        }
-       
+
+       /**
+        * @param int $bytes
+        */
        function read($bytes) {
                return fread($this->_f, $bytes);
        }
-       
+
+       /**
+        * @param int $pos
+        * @return boolean
+        */
        function seekto($pos) {
                if ( -1 == fseek($this->_f, $pos, SEEK_SET)) {
                        return false;
@@ -120,19 +145,19 @@ class POMO_FileReader extends POMO_Reader {
                $this->_pos = $pos;
                return true;
        }
-       
+
        function is_resource() {
                return is_resource($this->_f);
        }
-       
+
        function feof() {
                return feof($this->_f);
        }
-       
+
        function close() {
                return fclose($this->_f);
        }
-       
+
        function read_all() {
                $all = '';
                while ( !$this->feof() )
@@ -148,16 +173,19 @@ if ( !class_exists( 'POMO_StringReader' ) ):
  * of a physical file.
  */
 class POMO_StringReader extends POMO_Reader {
-       
+
        var $_str = '';
-       
+
        function POMO_StringReader($str = '') {
                parent::POMO_Reader();
                $this->_str = $str;
                $this->_pos = 0;
        }
 
-
+       /**
+        * @param string $bytes
+        * @return string
+        */
        function read($bytes) {
                $data = $this->substr($this->_str, $this->_pos, $bytes);
                $this->_pos += $bytes;
@@ -165,6 +193,10 @@ class POMO_StringReader extends POMO_Reader {
                return $data;
        }
 
+       /**
+        * @param int $pos
+        * @return int
+        */
        function seekto($pos) {
                $this->_pos = $pos;
                if ($this->strlen($this->_str) < $this->_pos) $this->_pos = $this->strlen($this->_str);
@@ -178,7 +210,7 @@ class POMO_StringReader extends POMO_Reader {
        function read_all() {
                return $this->substr($this->_str, $this->_pos, $this->strlen($this->_str));
        }
-       
+
 }
 endif;