summaryrefslogtreecommitdiff
path: root/includes/json/Services_JSON.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-06-22 11:28:20 +0200
committerPierre Schmitz <pierre@archlinux.de>2011-06-22 11:28:20 +0200
commit9db190c7e736ec8d063187d4241b59feaf7dc2d1 (patch)
tree46d1a0dee7febef5c2d57a9f7b972be16a163b3d /includes/json/Services_JSON.php
parent78677c7bbdcc9739f6c10c75935898a20e1acd9e (diff)
update to MediaWiki 1.17.0
Diffstat (limited to 'includes/json/Services_JSON.php')
-rw-r--r--includes/json/Services_JSON.php48
1 files changed, 27 insertions, 21 deletions
diff --git a/includes/json/Services_JSON.php b/includes/json/Services_JSON.php
index 588ece9c..5b4e0503 100644
--- a/includes/json/Services_JSON.php
+++ b/includes/json/Services_JSON.php
@@ -45,12 +45,13 @@
* 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 79562 2011-01-04 06:15:54Z tstarling $
+* @version CVS: $Id: Services_JSON.php 90492 2011-06-20 22:39:10Z reedy $
* @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;
}
}
}