diff --git a/src/Encoder.php b/src/Encoder.php index 3c206f46f..3d8b50257 100644 --- a/src/Encoder.php +++ b/src/Encoder.php @@ -427,7 +427,7 @@ public static function encodeClasses(array $classNames, $package = '') { $result = ''; foreach ($classNames as $className) { - $result .= self::encodeClass($className, $package); + $result .= static::encodeClass($className, $package); } return $result; diff --git a/src/Json.php b/src/Json.php index ef76d817e..1c8bcd565 100644 --- a/src/Json.php +++ b/src/Json.php @@ -57,7 +57,7 @@ class Json public static function decode($encodedValue, $objectDecodeType = self::TYPE_OBJECT) { $encodedValue = (string) $encodedValue; - if (function_exists('json_decode') && self::$useBuiltinEncoderDecoder !== true) { + if (function_exists('json_decode') && static::$useBuiltinEncoderDecoder !== true) { $decode = json_decode($encodedValue, $objectDecodeType); switch (json_last_error()) { @@ -105,7 +105,7 @@ public static function encode($valueToEncode, $cycleCheck = false, $options = ar if (method_exists($valueToEncode, 'toJson')) { return $valueToEncode->toJson(); } elseif (method_exists($valueToEncode, 'toArray')) { - return self::encode($valueToEncode->toArray(), $cycleCheck, $options); + return static::encode($valueToEncode->toArray(), $cycleCheck, $options); } } @@ -114,11 +114,11 @@ public static function encode($valueToEncode, $cycleCheck = false, $options = ar if (isset($options['enableJsonExprFinder']) && ($options['enableJsonExprFinder'] == true) ) { - $valueToEncode = self::_recursiveJsonExprFinder($valueToEncode, $javascriptExpressions); + $valueToEncode = static::_recursiveJsonExprFinder($valueToEncode, $javascriptExpressions); } // Encoding - if (function_exists('json_encode') && self::$useBuiltinEncoderDecoder !== true) { + if (function_exists('json_encode') && static::$useBuiltinEncoderDecoder !== true) { $encodedResult = json_encode( $valueToEncode, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP @@ -175,11 +175,11 @@ protected static function _recursiveJsonExprFinder( $value = $magicKey; } elseif (is_array($value)) { foreach ($value as $k => $v) { - $value[$k] = self::_recursiveJsonExprFinder($value[$k], $javascriptExpressions, $k); + $value[$k] = static::_recursiveJsonExprFinder($value[$k], $javascriptExpressions, $k); } } elseif (is_object($value)) { foreach ($value as $k => $v) { - $value->$k = self::_recursiveJsonExprFinder($value->$k, $javascriptExpressions, $k); + $value->$k = static::_recursiveJsonExprFinder($value->$k, $javascriptExpressions, $k); } } return $value; @@ -229,23 +229,23 @@ protected static function _getXmlValue($simpleXmlElementObject) protected static function _processXml($simpleXmlElementObject, $ignoreXmlAttributes, $recursionDepth = 0) { // Keep an eye on how deeply we are involved in recursion. - if ($recursionDepth > self::$maxRecursionDepthAllowed) { + if ($recursionDepth > static::$maxRecursionDepthAllowed) { // XML tree is too deep. Exit now by throwing an exception. throw new RecursionException( "Function _processXml exceeded the allowed recursion depth of " - . self::$maxRecursionDepthAllowed + . static::$maxRecursionDepthAllowed ); } $children = $simpleXmlElementObject->children(); $name = $simpleXmlElementObject->getName(); - $value = self::_getXmlValue($simpleXmlElementObject); + $value = static::_getXmlValue($simpleXmlElementObject); $attributes = (array) $simpleXmlElementObject->attributes(); if (!count($children)) { if (!empty($attributes) && !$ignoreXmlAttributes) { foreach ($attributes['@attributes'] as $k => $v) { - $attributes['@attributes'][$k] = self::_getXmlValue($v); + $attributes['@attributes'][$k] = static::_getXmlValue($v); } if (!empty($value)) { $attributes['@text'] = $value; @@ -259,7 +259,7 @@ protected static function _processXml($simpleXmlElementObject, $ignoreXmlAttribu $childArray = array(); foreach ($children as $child) { $childname = $child->getName(); - $element = self::_processXml($child, $ignoreXmlAttributes, $recursionDepth + 1); + $element = static::_processXml($child, $ignoreXmlAttributes, $recursionDepth + 1); if (array_key_exists($childname, $childArray)) { if (empty($subChild[$childname])) { $childArray[$childname] = array($childArray[$childname]); @@ -273,7 +273,7 @@ protected static function _processXml($simpleXmlElementObject, $ignoreXmlAttribu if (!empty($attributes) && !$ignoreXmlAttributes) { foreach ($attributes['@attributes'] as $k => $v) { - $attributes['@attributes'][$k] = self::_getXmlValue($v); + $attributes['@attributes'][$k] = static::_getXmlValue($v); } $childArray['@attributes'] = $attributes['@attributes']; } @@ -323,11 +323,11 @@ public static function fromXml ($xmlStringContents, $ignoreXmlAttributes=true) $resultArray = null; // Call the recursive function to convert the XML into a PHP array. - $resultArray = self::_processXml($simpleXmlElementObject, $ignoreXmlAttributes); + $resultArray = static::_processXml($simpleXmlElementObject, $ignoreXmlAttributes); // Convert the PHP array to JSON using Zend_Json encode method. // It is just that simple. - $jsonStringOutput = self::encode($resultArray); + $jsonStringOutput = static::encode($resultArray); return($jsonStringOutput); } diff --git a/src/Server/Response.php b/src/Server/Response.php index 8365f626e..3c30b6be4 100644 --- a/src/Server/Response.php +++ b/src/Server/Response.php @@ -118,10 +118,10 @@ public function getResult() /** * Set result error * - * @param Error $error + * @param mixed $error * @return Response */ - public function setError(Error $error) + public function setError(Error $error = null) { $this->error = $error; return $this; diff --git a/src/Server/Smd.php b/src/Server/Smd.php index 88a7801fe..669783b5e 100644 --- a/src/Server/Smd.php +++ b/src/Server/Smd.php @@ -382,7 +382,7 @@ public function toArray() $transport = $this->getTransport(); $envelope = $this->getEnvelope(); $contentType = $this->getContentType(); - $SMDVersion = self::SMD_VERSION; + $SMDVersion = static::SMD_VERSION; $service = compact('transport', 'envelope', 'contentType', 'SMDVersion'); if (null !== ($target = $this->getTarget())) { diff --git a/test/Server/ResponseTest.php b/test/Server/ResponseTest.php index 865d8619a..2cca7b5d2 100644 --- a/test/Server/ResponseTest.php +++ b/test/Server/ResponseTest.php @@ -67,6 +67,13 @@ public function testShouldBeAbleToRetrieveErrorObject() $this->assertSame($error, $this->response->getError()); } + public function testErrorAccesorsShouldWorkWithNullInput() + { + $this->response->setError(null); + $this->assertNull($this->response->getError()); + $this->assertFalse($this->response->isError()); + } + public function testIdShouldBeNullByDefault() { $this->assertNull($this->response->getId());