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

Commit

Permalink
Merge branch 'master' into acceptHandling
Browse files Browse the repository at this point in the history
Conflicts:
	library/Zend/Http/Header/AbstractAccept.php
	library/Zend/Http/Header/AcceptEncoding.php
	library/Zend/Http/Header/AcceptLanguage.php
	tests/Zend/Http/Header/AcceptCharsetTest.php
	tests/Zend/Http/Header/AcceptEncodingTest.php
	tests/Zend/Http/Header/AcceptLanguageTest.php
	tests/Zend/Http/Header/AcceptTest.php
  • Loading branch information
Freeaqingme committed Jul 14, 2012
5 parents c595ae1 + bfcf88b + e2e6ee0 + bd53446 + 62fffaa commit 075b3a5
Show file tree
Hide file tree
Showing 18 changed files with 79 additions and 72 deletions.
4 changes: 2 additions & 2 deletions src/Encoder.php
Expand Up @@ -84,7 +84,7 @@ protected function _encodeValue(&$value)
{
if (is_object($value)) {
return $this->_encodeObject($value);
} else if (is_array($value)) {
} elseif (is_array($value)) {
return $this->_encodeArray($value);
}

Expand Down Expand Up @@ -148,7 +148,7 @@ protected function _encodeObject(&$value)
}

$className = get_class($value);
return '{"__className":'
return '{"__className":'
. $this->_encodeString($className)
. $props . '}';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/BadMethodCallException.php
Expand Up @@ -15,6 +15,6 @@
* @package Zend_Json
* @subpackage Exception
*/
class BadMethodCallException extends \BadMethodCallException implements
class BadMethodCallException extends \BadMethodCallException implements
ExceptionInterface
{}
2 changes: 1 addition & 1 deletion src/Exception/InvalidArgumentException.php
Expand Up @@ -14,6 +14,6 @@
* @category Zend
* @package Zend_Json
*/
class InvalidArgumentException extends \InvalidArgumentException implements
class InvalidArgumentException extends \InvalidArgumentException implements
ExceptionInterface
{}
23 changes: 12 additions & 11 deletions src/Json.php
Expand Up @@ -194,7 +194,7 @@ protected static function _recursiveJsonExprFinder(
* @param SimpleXMLElement $simpleXmlElementObject
* @return Zend_Json_Expr|string
*/
protected static function _getXmlValue($simpleXmlElementObject)
protected static function _getXmlValue($simpleXmlElementObject)
{
$pattern = '/^[\s]*new Zend[_\\]Json[_\\]Expr[\s]*\([\s]*[\"\']{1}(.*)[\"\']{1}[\s]*\)[\s]*$/';
$matchings = array();
Expand Down Expand Up @@ -226,13 +226,13 @@ protected static function _getXmlValue($simpleXmlElementObject)
* @param integer $recursionDepth
* @return array
*/
protected static function _processXml($simpleXmlElementObject, $ignoreXmlAttributes, $recursionDepth = 0)
protected static function _processXml($simpleXmlElementObject, $ignoreXmlAttributes, $recursionDepth = 0)
{
// Keep an eye on how deeply we are involved in recursion.
if ($recursionDepth > self::$maxRecursionDepthAllowed) {
// XML tree is too deep. Exit now by throwing an exception.
throw new RecursionException(
"Function _processXml exceeded the allowed recursion depth of "
"Function _processXml exceeded the allowed recursion depth of "
. self::$maxRecursionDepthAllowed
);
}
Expand All @@ -249,7 +249,7 @@ protected static function _processXml($simpleXmlElementObject, $ignoreXmlAttribu
}
if (!empty($value)) {
$attributes['@text'] = $value;
}
}
return array($name => $attributes);
}

Expand Down Expand Up @@ -310,7 +310,8 @@ protected static function _processXml($simpleXmlElementObject, $ignoreXmlAttribu
* @return mixed - JSON formatted string on success
* @throws \Zend\Json\Exception\RuntimeException if the input not a XML formatted string
*/
public static function fromXml ($xmlStringContents, $ignoreXmlAttributes=true) {
public static function fromXml ($xmlStringContents, $ignoreXmlAttributes=true)
{
// Load the XML formatted string into a Simple XML Element object.
$simpleXmlElementObject = simplexml_load_string($xmlStringContents);

Expand All @@ -332,9 +333,9 @@ public static function fromXml ($xmlStringContents, $ignoreXmlAttributes=true) {

/**
* Pretty-print JSON string
*
*
* Use 'indent' option to select indentation string - by default it's a tab
*
*
* @param string $json Original JSON string
* @param array $options Encoding options
* @return string
Expand All @@ -344,16 +345,16 @@ public static function prettyPrint($json, $options = array())
$tokens = preg_split('|([\{\}\]\[,])|', $json, -1, PREG_SPLIT_DELIM_CAPTURE);
$result = "";
$indent = 0;

$ind = "\t";
if(isset($options['indent'])) {
$ind = $options['indent'];
}

$inLiteral = false;
foreach($tokens as $token) {
if($token == "") continue;

$prefix = str_repeat($ind, $indent);
if(!$inLiteral && ($token == "{" || $token == "[")) {
$indent++;
Expand All @@ -364,7 +365,7 @@ public static function prettyPrint($json, $options = array())
} else if(!$inLiteral && ($token == "}" || $token == "]")) {
$indent--;
$prefix = str_repeat($ind, $indent);
$result .= "\n$prefix$token";
$result .= "\n$prefix$token";
} else if(!$inLiteral && $token == ",") {
$result .= "$token\n";
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Server/Exception/ErrorException.php
Expand Up @@ -19,6 +19,6 @@
* @package Zend_Json
* @subpackage Server
*/
class ErrorException extends Exception\BadMethodCallException implements
class ErrorException extends Exception\BadMethodCallException implements
ExceptionInterface
{}
2 changes: 1 addition & 1 deletion src/Server/Exception/InvalidArgumentException.php
Expand Up @@ -17,6 +17,6 @@
* @package Zend_Json
* @subpackage Server
*/
class InvalidArgumentException extends Exception\InvalidArgumentException implements
class InvalidArgumentException extends Exception\InvalidArgumentException implements
ExceptionInterface
{}
2 changes: 1 addition & 1 deletion src/Server/Exception/RuntimeException.php
Expand Up @@ -17,6 +17,6 @@
* @package Zend_Json
* @subpackage Server
*/
class RuntimeException extends Exception\RuntimeException implements
class RuntimeException extends Exception\RuntimeException implements
ExceptionInterface
{}
4 changes: 2 additions & 2 deletions src/Server/Server.php
Expand Up @@ -514,8 +514,8 @@ protected function _handle()
if ('function' == $callback->getType()) {
$reflection = new ReflectionFunction( $callback->getFunction() );
} else {
$reflection = new ReflectionMethod(

$reflection = new ReflectionMethod(
$callback->getClass(),
$callback->getMethod()
);
Expand Down
18 changes: 9 additions & 9 deletions test/JsonTest.php
Expand Up @@ -732,15 +732,15 @@ public function testEncodeObjectImplementingIterator()
{
$this->markTestIncomplete('Test is not yet finished.');
}

/**
* @group ZF-8663
*/
public function testNativeJSONEncoderWillProperlyEncodeSolidusInStringValues()
{
$source = "</foo><foo>bar</foo>";
$target = '"\u003C\/foo\u003E\u003Cfoo\u003Ebar\u003C\/foo\u003E"';

// first test ext/json
Json\Json::$useBuiltinEncoderDecoder = false;
$this->assertEquals($target, Json\Json::encode($source));
Expand All @@ -750,20 +750,20 @@ public function testNativeJSONEncoderWillProperlyEncodeHtmlSpecialCharsInStringV
{
$source = "<>&'\"";
$target = '"\u003C\u003E\u0026\u0027\u0022"';

// first test ext/json
Json\Json::$useBuiltinEncoderDecoder = false;
$this->assertEquals($target, Json\Json::encode($source));
}

/**
* @group ZF-8663
*/
public function testBuiltinJSONEncoderWillProperlyEncodeSolidusInStringValues()
{
$source = "</foo><foo>bar</foo>";
$target = '"\u003C\/foo\u003E\u003Cfoo\u003Ebar\u003C\/foo\u003E"';

// first test ext/json
Json\Json::$useBuiltinEncoderDecoder = true;
$this->assertEquals($target, Json\Json::encode($source));
Expand All @@ -773,12 +773,12 @@ public function testBuiltinJSONEncoderWillProperlyEncodeHtmlSpecialCharsInString
{
$source = "<>&'\"";
$target = '"\u003C\u003E\u0026\u0027\u0022"';

// first test ext/json
Json\Json::$useBuiltinEncoderDecoder = true;
$this->assertEquals($target, Json\Json::encode($source));
}

/**
* @group ZF-8918
*/
Expand Down Expand Up @@ -958,7 +958,7 @@ public function toJSON()

/**
* Serializable class exposing a toArray() method
* @see ZF-11167
* @group ZF-11167
*/
class ZF11167_ToArrayClass
{
Expand All @@ -981,7 +981,7 @@ public function toArray()

/**
* Serializable class exposing both toArray() and toJson() methods
* @see ZF-11167
* @group ZF-11167
*/
class ZF11167_ToArrayToJsonClass extends ZF11167_ToArrayClass
{
Expand Down
73 changes: 37 additions & 36 deletions test/JsonXmlTest.php
Expand Up @@ -9,6 +9,7 @@
*/

namespace ZendTest\Json;

use Zend\Json;

error_reporting( E_ALL | E_STRICT ); // now required for each test suite
Expand Down Expand Up @@ -495,8 +496,8 @@ public function testUsingXML7()
/**
* @group ZF-3257
*/
public function testUsingXML8() {

public function testUsingXML8()
{
// Set the XML contents that will be tested here.
$xmlStringContents = <<<EOT
<?xml version="1.0"?>
Expand Down Expand Up @@ -561,40 +562,40 @@ public static function providerNestingDepthIsHandledProperly()
{
$xmlStringContents = <<<EOT
<response>
<status>success</status>
<description>200 OK</description>
<message_type>
<system_name>A</system_name>
<shortname>B</shortname>
<long_name>C</long_name>
<as_verb>D</as_verb>
<as_noun>E</as_noun>
<challenge_phrase>F</challenge_phrase>
<recipient_details>G</recipient_details>
<sender_details>H</sender_details>
<example_text>A</example_text>
<short_description>B</short_description>
<long_description>C</long_description>
<version>D</version>
<developer>E</developer>
<config_instructions>A</config_instructions>
<config_fragment>B</config_fragment>
<icon_small>C</icon_small>
<icon_medium>D</icon_medium>
<icon_large>E</icon_large>
<defaults>
<close_rules>
<after_responses>A</after_responses>
</close_rules>
<recipient_visibility>B</recipient_visibility>
<recipient_invite>C</recipient_invite>
<results_visibility>A</results_visibility>
<response_visibility>B</response_visibility>
<recipient_resubmit>C</recipient_resubmit>
<feed_status>D</feed_status>
</defaults>
</message_type>
<execution_time>0.0790269374847</execution_time>
<status>success</status>
<description>200 OK</description>
<message_type>
<system_name>A</system_name>
<shortname>B</shortname>
<long_name>C</long_name>
<as_verb>D</as_verb>
<as_noun>E</as_noun>
<challenge_phrase>F</challenge_phrase>
<recipient_details>G</recipient_details>
<sender_details>H</sender_details>
<example_text>A</example_text>
<short_description>B</short_description>
<long_description>C</long_description>
<version>D</version>
<developer>E</developer>
<config_instructions>A</config_instructions>
<config_fragment>B</config_fragment>
<icon_small>C</icon_small>
<icon_medium>D</icon_medium>
<icon_large>E</icon_large>
<defaults>
<close_rules>
<after_responses>A</after_responses>
</close_rules>
<recipient_visibility>B</recipient_visibility>
<recipient_invite>C</recipient_invite>
<results_visibility>A</results_visibility>
<response_visibility>B</response_visibility>
<recipient_resubmit>C</recipient_resubmit>
<feed_status>D</feed_status>
</defaults>
</message_type>
<execution_time>0.0790269374847</execution_time>
</response>
EOT;
return array(array($xmlStringContents));
Expand Down
1 change: 1 addition & 0 deletions test/Server/CacheTest.php
Expand Up @@ -9,6 +9,7 @@
*/

namespace ZendTest\Json\Server;

use Zend\Json\Server;

/**
Expand Down
2 changes: 0 additions & 2 deletions test/Server/ClientTest.php
Expand Up @@ -18,8 +18,6 @@
use Zend\Json\Server\Response;

/**
* Test case for Zend\Json\Server\Client
*
* @category Zend
* @package Zend_Json
* @subpackage UnitTests
Expand Down
1 change: 1 addition & 0 deletions test/Server/ErrorTest.php
Expand Up @@ -9,6 +9,7 @@
*/

namespace ZendTest\Json\Server;

use Zend\Json\Server;
use Zend\Json;

Expand Down
1 change: 1 addition & 0 deletions test/Server/RequestTest.php
Expand Up @@ -9,6 +9,7 @@
*/

namespace ZendTest\Json\Server;

use Zend\Json;

/**
Expand Down
1 change: 1 addition & 0 deletions test/Server/ResponseTest.php
Expand Up @@ -9,6 +9,7 @@
*/

namespace ZendTest\Json\Server;

use Zend\Json\Server;
use Zend\Json;

Expand Down
7 changes: 4 additions & 3 deletions test/Server/Smd/ServiceTest.php
Expand Up @@ -9,6 +9,7 @@
*/

namespace ZendTest\Json\Server\Smd;

use Zend\Json\Server\Smd\Service;
use Zend\Json\Server;

Expand Down Expand Up @@ -39,7 +40,7 @@ public function testConstructorShouldThrowExceptionWhenNoNameSetWhenNullProvided
$this->setExpectedException('Zend\Json\Server\Exception\InvalidArgumentException', 'requires a name');
$service = new Service(null);
}

public function testConstructorShouldThrowExceptionWhenNoNameSetWhenArrayProvided()
{
$this->setExpectedException('Zend\Json\Server\Exception\InvalidArgumentException', 'requires a name');
Expand All @@ -57,7 +58,7 @@ public function testSettingNameShouldThrowExceptionWhenContainingInvalidFormatSt
$this->setExpectedException('Zend\Json\Server\Exception\InvalidArgumentException', 'Invalid name');
$this->service->setName('0ab-?');
}

public function testNameAccessorsShouldWorkWithNormalInput()
{
$this->assertEquals('foo', $this->service->getName());
Expand All @@ -81,7 +82,7 @@ public function testSettingTransportThrowsExceptionWhenSetToRest()
$this->setExpectedException('Zend\Json\Server\Exception\InvalidArgumentException', 'Invalid transport');
$this->service->setTransport('REST');
}

public function testTransportAccessorsShouldWorkUnderNormalInput()
{
$this->service->setTransport('POST');
Expand Down

0 comments on commit 075b3a5

Please sign in to comment.