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' of git://github.com/zendframework/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
tr committed Aug 13, 2012
3 parents 8474496 + 7c3bb76 + bada1dc commit a262925
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/Decoder.php
Expand Up @@ -371,7 +371,7 @@ protected function _getNextToken()
default:
throw new RuntimeException("Illegal escape sequence '{$chr}'");
}
} elseif($chr == '"') {
} elseif ($chr == '"') {
break;
} else {
$result .= $chr;
Expand Down Expand Up @@ -457,7 +457,7 @@ public static function decodeUnicodeString($chrs)
$utf8 = '';
$strlen_chrs = strlen($chrs);

for($i = 0; $i < $strlen_chrs; $i++) {
for ($i = 0; $i < $strlen_chrs; $i++) {

$substr_chrs_c_2 = substr($chrs, $i, 2);
$ord_chrs_c = ord($chrs[$i]);
Expand Down Expand Up @@ -531,7 +531,7 @@ public static function decodeUnicodeString($chrs)
protected static function _utf162utf8($utf16)
{
// Check for mb extension otherwise do by hand.
if( function_exists('mb_convert_encoding') ) {
if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}

Expand Down
4 changes: 2 additions & 2 deletions src/Encoder.php
Expand Up @@ -453,7 +453,7 @@ public static function encodeUnicodeString($value)
* Iterate over every character in the string,
* escaping with a slash or encoding to UTF-8 where necessary
*/
for($i = 0; $i < $strlen_var; $i++) {
for ($i = 0; $i < $strlen_var; $i++) {
$ord_var_c = ord($value[$i]);

switch (true) {
Expand Down Expand Up @@ -542,7 +542,7 @@ public static function encodeUnicodeString($value)
protected static function _utf82utf16($utf8)
{
// Check for mb extension otherwise do by hand.
if( function_exists('mb_convert_encoding') ) {
if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
}

Expand Down
4 changes: 2 additions & 2 deletions src/Expr.php
Expand Up @@ -23,13 +23,13 @@
* 'integer' =>9,
* 'string' =>'test string',
* 'function' => Zend_Json_Expr(
* 'function(){ window.alert("javascript function encoded by Zend_Json") }'
* 'function() { window.alert("javascript function encoded by Zend_Json") }'
* ),
* );
*
* Zend_Json::encode($foo, false, array('enableJsonExprFinder' => true));
* // it will returns json encoded string:
* // {"integer":9,"string":"test string","function":function(){window.alert("javascript function encoded by Zend_Json")}}
* // {"integer":9,"string":"test string","function":function() {window.alert("javascript function encoded by Zend_Json")}}
* </code>
*
* @category Zend
Expand Down
18 changes: 9 additions & 9 deletions src/Json.php
Expand Up @@ -110,7 +110,7 @@ public static function encode($valueToEncode, $cycleCheck = false, $options = ar

// Pre-encoding look for Zend_Json_Expr objects and replacing by tmp ids
$javascriptExpressions = array();
if(isset($options['enableJsonExprFinder'])
if (isset($options['enableJsonExprFinder'])
&& ($options['enableJsonExprFinder'] == true)
) {
$valueToEncode = self::_recursiveJsonExprFinder($valueToEncode, $javascriptExpressions);
Expand All @@ -129,7 +129,7 @@ public static function encode($valueToEncode, $cycleCheck = false, $options = ar
//only do post-processing to revert back the Zend_Json_Expr if any.
if (count($javascriptExpressions) > 0) {
$count = count($javascriptExpressions);
for($i = 0; $i < $count; $i++) {
for ($i = 0; $i < $count; $i++) {
$magicKey = $javascriptExpressions[$i]['magicKey'];
$value = $javascriptExpressions[$i]['value'];

Expand Down Expand Up @@ -347,26 +347,26 @@ public static function prettyPrint($json, $options = array())
$indent = 0;

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

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

$prefix = str_repeat($ind, $indent);
if(!$inLiteral && ($token == "{" || $token == "[")) {
if (!$inLiteral && ($token == "{" || $token == "[")) {
$indent++;
if($result != "" && $result[strlen($result)-1] == "\n") {
if ($result != "" && $result[strlen($result)-1] == "\n") {
$result .= $prefix;
}
$result .= "$token\n";
} else if(!$inLiteral && ($token == "}" || $token == "]")) {
} elseif (!$inLiteral && ($token == "}" || $token == "]")) {
$indent--;
$prefix = str_repeat($ind, $indent);
$result .= "\n$prefix$token";
} else if(!$inLiteral && $token == ",") {
} elseif (!$inLiteral && $token == ",") {
$result .= "$token\n";
} else {
$result .= ($inLiteral ? '' : $prefix) . $token;
Expand Down
8 changes: 4 additions & 4 deletions src/Server/Server.php
Expand Up @@ -508,7 +508,7 @@ protected function _handle()
}

//Make sure named parameters are passed in correct order
if ( is_string( key( $params ) ) ) {
if (is_string( key( $params ) )) {

$callback = $invocable->getCallback();
if ('function' == $callback->getType()) {
Expand All @@ -522,10 +522,10 @@ protected function _handle()
}

$orderedParams = array();
foreach( $reflection->getParameters() as $refParam ) {
if( isset( $params[ $refParam->getName() ] ) ) {
foreach ($reflection->getParameters() as $refParam) {
if (isset( $params[ $refParam->getName() ] )) {
$orderedParams[ $refParam->getName() ] = $params[ $refParam->getName() ];
} elseif( $refParam->isOptional() ) {
} elseif ($refParam->isOptional()) {
$orderedParams[ $refParam->getName() ] = null;
} else {
return $this->fault('Invalid params', Error::ERROR_INVALID_PARAMS);
Expand Down
12 changes: 6 additions & 6 deletions test/JsonTest.php
Expand Up @@ -503,7 +503,7 @@ public function testEncodingObjectWithExprAndInternalEncoder()
*/
public function testEncodingObjectWithExprAndExtJSON()
{
if(!function_exists('json_encode')) {
if (!function_exists('json_encode')) {
$this->markTestSkipped('Test only works with ext/json enabled!');
}

Expand Down Expand Up @@ -543,12 +543,12 @@ public function testEncodingMultipleNestedSwitchingSameNameKeysWithDifferentJSON
{
$data = array(
0 => array(
"alpha" => new Json\Expr("function(){}"),
"alpha" => new Json\Expr("function() {}"),
"beta" => "gamma",
),
1 => array(
"alpha" => "gamma",
"beta" => new Json\Expr("function(){}"),
"beta" => new Json\Expr("function() {}"),
),
2 => array(
"alpha" => "gamma",
Expand All @@ -558,7 +558,7 @@ public function testEncodingMultipleNestedSwitchingSameNameKeysWithDifferentJSON
$result = Json\Json::encode($data, false, array('enableJsonExprFinder' => true));

$this->assertEquals(
'[{"alpha":function(){},"beta":"gamma"},{"alpha":"gamma","beta":function(){}},{"alpha":"gamma","beta":"gamma"}]',
'[{"alpha":function() {},"beta":"gamma"},{"alpha":"gamma","beta":function() {}},{"alpha":"gamma","beta":"gamma"}]',
$result
);
}
Expand Down Expand Up @@ -598,7 +598,7 @@ public function testDisabledJSONExprFinder()

$data = array(
0 => array(
"alpha" => new Json\Expr("function(){}"),
"alpha" => new Json\Expr("function() {}"),
"beta" => "gamma",
),
);
Expand Down Expand Up @@ -682,7 +682,7 @@ public function testDecodeUnicodeStringSolarRegression()
*/
public function testEncodeWithUtf8IsTransformedSolarRegressionEqualsJSONExt()
{
if(function_exists('json_encode') == false) {
if (function_exists('json_encode') == false) {
$this->markTestSkipped('Test can only be run, when ext/json is installed.');
}

Expand Down

0 comments on commit a262925

Please sign in to comment.