Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 27 deletions.
8 changes: 5 additions & 3 deletions src/Decoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Zend\Json;

use stdClass;
use Zend\Json\Exception\InvalidArgumentException;
use Zend\Json\Exception\RuntimeException;

Expand Down Expand Up @@ -85,6 +86,7 @@ class Decoder
* @param int $decodeType How objects should be decoded -- see
* {@link Zend_Json::TYPE_ARRAY} and {@link Zend_Json::TYPE_OBJECT} for
* valid values
* @throws InvalidArgumentException
* @return void
*/
protected function __construct($source, $decodeType)
Expand Down Expand Up @@ -176,7 +178,7 @@ protected function _decodeValue()
* {@link $decodeType}. If invalid $decodeType present, returns as an
* array.
*
* @return array|StdClass
* @return array|stdClass
* @throws Zend\Json\Exception\RuntimeException
*/
protected function _decodeObject()
Expand Down Expand Up @@ -214,7 +216,7 @@ protected function _decodeObject()
switch ($this->decodeType) {
case Json::TYPE_OBJECT:
// Create new StdClass and populate with $members
$result = new \stdClass();
$result = new stdClass();
foreach ($members as $key => $value) {
if ($key === '') {
$key = '_empty_';
Expand Down Expand Up @@ -447,7 +449,7 @@ protected function _getNextToken()
*
* @link http://solarphp.com/
* @link http://svn.solarphp.com/core/trunk/Solar/Json.php
* @param string $value
* @param string $chrs
* @return string
*/
public static function decodeUnicodeString($chrs)
Expand Down
17 changes: 9 additions & 8 deletions src/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Iterator;
use IteratorAggregate;
use ReflectionClass;
use Zend\Json\Exception\InvalidArgumentException;
use Zend\Json\Exception\RecursionException;

Expand Down Expand Up @@ -49,7 +50,7 @@ class Encoder
*
* @param boolean $cycleCheck Whether or not to check for recursion when encoding
* @param array $options Additional options used during encoding
* @return void
* @return Encoder
*/
protected function __construct($cycleCheck = false, $options = array())
{
Expand Down Expand Up @@ -247,7 +248,7 @@ protected function _encodeDatum(&$value)
/**
* JSON encode a string value by escaping characters as necessary
*
* @param $value string
* @param string $string
* @return string
*/
protected function _encodeString(&$string)
Expand All @@ -272,10 +273,10 @@ protected function _encodeString(&$string)
* Encode the constants associated with the ReflectionClass
* parameter. The encoding format is based on the class2 format
*
* @param $cls ReflectionClass
* @param ReflectionClass $cls
* @return string Encoded constant block in class2 format
*/
private static function _encodeConstants(\ReflectionClass $cls)
private static function _encodeConstants(ReflectionClass $cls)
{
$result = "constants : {";
$constants = $cls->getConstants();
Expand All @@ -297,11 +298,11 @@ private static function _encodeConstants(\ReflectionClass $cls)
* Encode the public methods of the ReflectionClass in the
* class2 format
*
* @param $cls ReflectionClass
* @param ReflectionClass $cls
* @return string Encoded method fragment
*
*/
private static function _encodeMethods(\ReflectionClass $cls)
private static function _encodeMethods(ReflectionClass $cls)
{
$methods = $cls->getMethods();
$result = 'methods:{';
Expand Down Expand Up @@ -361,11 +362,11 @@ private static function _encodeMethods(\ReflectionClass $cls)
* Encode the public properties of the ReflectionClass in the class2
* format.
*
* @param $cls ReflectionClass
* @param ReflectionClass $cls
* @return string Encode properties list
*
*/
private static function _encodeVariables(\ReflectionClass $cls)
private static function _encodeVariables(ReflectionClass $cls)
{
$properties = $cls->getProperties();
$propValues = get_class_vars($cls->getName());
Expand Down
7 changes: 4 additions & 3 deletions src/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Zend\Json;

use SimpleXMLElement;
use Zend\Json\Exception\RecursionException;
use Zend\Json\Exception\RuntimeException;

Expand Down Expand Up @@ -192,7 +193,7 @@ protected static function _recursiveJsonExprFinder(
* if it matches, we return a new Zend_Json_Expr instead of a text node
*
* @param SimpleXMLElement $simpleXmlElementObject
* @return Zend_Json_Expr|string
* @return Expr|string
*/
protected static function _getXmlValue($simpleXmlElementObject)
{
Expand All @@ -205,6 +206,7 @@ protected static function _getXmlValue($simpleXmlElementObject)
return (trim(strval($simpleXmlElementObject)));
}
}

/**
* _processXml - Contains the logic for xml2json
*
Expand All @@ -219,11 +221,10 @@ protected static function _getXmlValue($simpleXmlElementObject)
* calling a recursive (protected static) function in this class. Once all
* the XML elements are stored in the PHP array, it is returned to the caller.
*
* Throws a Zend\Json\RecursionException if the XML tree is deeper than the allowed limit.
*
* @param SimpleXMLElement $simpleXmlElementObject
* @param boolean $ignoreXmlAttributes
* @param integer $recursionDepth
* @throws Exception\RecursionException if the XML tree is deeper than the allowed limit.
* @return array
*/
protected static function _processXml($simpleXmlElementObject, $ignoreXmlAttributes, $recursionDepth = 0)
Expand Down
6 changes: 5 additions & 1 deletion src/Server/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class Server extends AbstractServer
*
* @param string|array|callable $function Valid PHP callback
* @param string $namespace Ignored
* @throws Exception\InvalidArgumentException if function invalid or not callable
* @return Server
*/
public function addFunction($function, $namespace = '')
Expand Down Expand Up @@ -145,7 +146,8 @@ public function setClass($class, $namespace = '', $argv = null)
*
* @param string $fault
* @param int $code
* @return false
* @param mixed $data
* @return Error
*/
public function fault($fault = null, $code = 404, $data = null)
{
Expand All @@ -158,6 +160,7 @@ public function fault($fault = null, $code = 404, $data = null)
* Handle request
*
* @param Request $request
* @throws Exception\InvalidArgumentException
* @return null|Response
*/
public function handle($request = false)
Expand Down Expand Up @@ -188,6 +191,7 @@ public function handle($request = false)
* Load function definitions
*
* @param array|Definition $definition
* @throws Exception\InvalidArgumentException
* @return void
*/
public function loadFunctions($definition)
Expand Down
7 changes: 6 additions & 1 deletion src/Server/Smd.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public function setOptions(array $options)
* Set transport
*
* @param string $transport
* @throws Exception\InvalidArgumentException
* @return \Zend\Json\Server\Smd
*/
public function setTransport($transport)
Expand All @@ -139,6 +140,7 @@ public function getTransport()
* Set envelope
*
* @param string $envelopeType
* @throws Exception\InvalidArgumentException
* @return Smd
*/
public function setEnvelope($envelopeType)
Expand All @@ -165,6 +167,7 @@ public function getEnvelope()
* Set content type
*
* @param string $type
* @throws Exception\InvalidArgumentException
* @return \Zend\Json\Server\Smd
*/
public function setContentType($type)
Expand Down Expand Up @@ -211,7 +214,7 @@ public function getTarget()
/**
* Set service ID
*
* @param string $Id
* @param string $id
* @return Smd
*/
public function setId($id)
Expand Down Expand Up @@ -278,6 +281,8 @@ public function isDojoCompatible()
* Add Service
*
* @param Smd\Service|array $service
* @throws Exception\RuntimeException
* @throws Exception\InvalidArgumentException
* @return Smd
*/
public function addService($service)
Expand Down
26 changes: 15 additions & 11 deletions src/Server/Smd/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Service
* Constructor
*
* @param string|array $spec
* @throws Zend\Json\Server\Exception\InvalidArgumentException if no name provided
* @throws InvalidArgumentException if no name provided
*/
public function __construct($spec)
{
Expand All @@ -126,7 +126,7 @@ public function __construct($spec)
* Set object state
*
* @param array $options
* @return Zend\Json\Server\Smd\Service
* @return Service
*/
public function setOptions(array $options)
{
Expand All @@ -147,8 +147,8 @@ public function setOptions(array $options)
* Set service name
*
* @param string $name
* @return Zend\Json\Server\Smd\Service
* @throws Zend\Json\Server\Exception\InvalidArgumentException
* @return Service
* @throws InvalidArgumentException
*/
public function setName($name)
{
Expand Down Expand Up @@ -176,7 +176,8 @@ public function getName()
* Currently limited to POST
*
* @param string $transport
* @return Zend\Json\Server\Smd\Service
* @throws InvalidArgumentException
* @return Service
*/
public function setTransport($transport)
{
Expand All @@ -202,7 +203,7 @@ public function getTransport()
* Set service target
*
* @param string $target
* @return Zend\Json\Server\Smd\Service
* @return Service
*/
public function setTarget($target)
{
Expand All @@ -224,7 +225,8 @@ public function getTarget()
* Set envelope type
*
* @param string $envelopeType
* @return Zend\Json\Server\Smd\Service
* @throws InvalidArgumentException
* @return Service
*/
public function setEnvelope($envelopeType)
{
Expand Down Expand Up @@ -252,7 +254,8 @@ public function getEnvelope()
* @param string|array $type
* @param array $options
* @param int|null $order
* @return Zend\Json\Server\Smd\Service
* @throws InvalidArgumentException
* @return Service
*/
public function addParam($type, array $options = array(), $order = null)
{
Expand Down Expand Up @@ -294,7 +297,7 @@ public function addParam($type, array $options = array(), $order = null)
* Each param should be an array, and should include the key 'type'.
*
* @param array $params
* @return Zend\Json\Server\Smd\Service
* @return Service
*/
public function addParams(array $params)
{
Expand All @@ -317,7 +320,7 @@ public function addParams(array $params)
* Overwrite all parameters
*
* @param array $params
* @return Zend\Json\Server\Smd\Service
* @return Service
*/
public function setParams(array $params)
{
Expand Down Expand Up @@ -355,7 +358,8 @@ public function getParams()
* Set return type
*
* @param string|array $type
* @return Zend\Json\Server\Smd\Service
* @throws InvalidArgumentException
* @return Service
*/
public function setReturn($type)
{
Expand Down

0 comments on commit 7f01229

Please sign in to comment.