]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blobdiff - includes/json/Services_JSON.php
MediaWiki 1.17.4
[autoinstalls/mediawiki.git] / includes / json / Services_JSON.php
index 9423352052f1e4d1e9dc6a7b2eafbd67b8b52900..2c83d19ca7b8403074303653fdaa995e1ac99729 100644 (file)
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 *
+* @file
 * @ingroup API
 * @author Michal Migurski <mike-json@teczno.com>
 * @author Matt Knapp <mdknapp[at]gmail[dot]com>
 * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
 * @copyright 2005 Michal Migurski
-* @version CVS: $Id: Services_JSON.php 65683 2010-04-30 05:56:15Z tstarling $
+* @version CVS: $Id$
 * @license http://www.opensource.org/licenses/bsd-license.php
 * @see http://pear.php.net/pepr/pepr-proposal-show.php?id=198
 */
@@ -118,7 +119,7 @@ class Services_JSON
        /**
         * constructs a new JSON instance
         *
-        * @param int $use object behavior flags; combine with boolean-OR
+        * @param $use Integer: object behavior flags; combine with boolean-OR
         *
         *      possible values:
         *      - SERVICES_JSON_LOOSE_TYPE:  loose typing.
@@ -131,7 +132,7 @@ class Services_JSON
         *                      bubble up with an error, so all return values
         *                      from encode() should be checked with isError()
         */
-       function Services_JSON($use = 0)
+       function __construct($use = 0)
        {
                $this->use = $use;
        }
@@ -156,8 +157,8 @@ class Services_JSON
         * provides a slower PHP-only method for installations
         * that lack the multibye string extension.
         *
-        * @param string  $utf16  UTF-16 character
-        * @return string  UTF-8 character
+        * @param $utf16 String: UTF-16 character
+        * @return String: UTF-8 character
         * @access private
         */
        function utf162utf8($utf16)
@@ -211,8 +212,8 @@ class Services_JSON
         * provides a slower PHP-only method for installations
         * that lack the multibye string extension.
         *
-        * @param string  $utf8   UTF-8 character
-        * @return string  UTF-16 character
+        * @param $utf8 String: UTF-8 character
+        * @return String: UTF-16 character
         * @access private
         */
        function utf82utf16($utf8)
@@ -265,11 +266,11 @@ class Services_JSON
        /**
         * encodes an arbitrary variable into JSON format
         *
-        * @param mixed $var any number, boolean, string, array, or object to be encoded.
+        * @param $var Mixed: any number, boolean, string, array, or object to be encoded.
         *                      see argument 1 to Services_JSON() above for array-parsing behavior.
         *                      if var is a strng, note that encode() always expects it
         *                      to be in ASCII or UTF-8 format!
-        * @param bool $pretty pretty-print output with indents and newlines
+        * @param $pretty Boolean: pretty-print output with indents and newlines
         *
         * @return mixed JSON string representation of input var or an error if a problem occurs
         * @access public
@@ -285,7 +286,7 @@ class Services_JSON
        /**
         * encodes an arbitrary variable into JSON format
         *
-        * @param mixed $var any number, boolean, string, array, or object to be encoded.
+        * @param $var Mixed: any number, boolean, string, array, or object to be encoded.
         *                      see argument 1 to Services_JSON() above for array-parsing behavior.
         *                      if var is a strng, note that encode() always expects it
         *                      to be in ASCII or UTF-8 format!
@@ -431,7 +432,7 @@ class Services_JSON
                                        $this->indent--;
 
                                        foreach($properties as $property) {
-                                               if(Services_JSON::isError($property)) {
+                                               if($this->isError($property)) {
                                                        return $property;
                                                }
                                        }
@@ -445,7 +446,7 @@ class Services_JSON
                                $this->indent--;
 
                                foreach($elements as $element) {
-                                       if(Services_JSON::isError($element)) {
+                                       if($this->isError($element)) {
                                                return $element;
                                        }
                                }
@@ -462,7 +463,7 @@ class Services_JSON
                                $this->indent--;
 
                                foreach($properties as $property) {
-                                       if(Services_JSON::isError($property)) {
+                                       if($this->isError($property)) {
                                                return $property;
                                        }
                                }
@@ -479,17 +480,17 @@ class Services_JSON
        /**
         * array-walking function for use in generating JSON-formatted name-value pairs
         *
-        * @param string $name name of key to use
-        * @param mixed $value reference to an array element to be encoded
+        * @param $name String: name of key to use
+        * @param $value Mixed: reference to an array element to be encoded
         *
-        * @return string JSON-formatted name-value pair, like '"name":value'
+        * @return String: JSON-formatted name-value pair, like '"name":value'
         * @access private
         */
        function name_value($name, $value)
        {
                $encoded_value = $this->encode2($value);
 
-               if(Services_JSON::isError($encoded_value)) {
+               if($this->isError($encoded_value)) {
                        return $encoded_value;
                }
 
@@ -499,9 +500,9 @@ class Services_JSON
        /**
         * reduce a string by removing leading and trailing comments and whitespace
         *
-        * @param $str string string value to strip of comments and whitespace
+        * @param $str String: string value to strip of comments and whitespace
         *
-        * @return string string value stripped of comments and whitespace
+        * @return String: string value stripped of comments and whitespace
         * @access private
         */
        function reduce_string($str)
@@ -526,7 +527,7 @@ class Services_JSON
        /**
         * decodes a JSON string into appropriate variable
         *
-        * @param string $str JSON-formatted string
+        * @param $str String: JSON-formatted string
         *
         * @return mixed number, boolean, string, array, or object
         *                 corresponding to given JSON input string.
@@ -869,7 +870,12 @@ if (class_exists('PEAR_Error')) {
                function Services_JSON_Error($message = 'unknown error', $code = null,
                                                $mode = null, $options = null, $userinfo = null)
                {
-
+                       $this->message = $message;
+               }
+               
+               function __toString()
+               {
+                       return $this->message;
                }
        }
 }