From bd5344647428a5faeee05fbfae94cdd1486de498 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Thu, 12 Jul 2012 21:11:36 +0200 Subject: [PATCH] [PSR-2] fixers=braces,elseif,short_tag,php_closing_tag,trailing_spaces,linefeed Applied php-cs-fixer --fixers=braces,elseif,short_tag,php_closing_tag,trailing_spaces,linefeed --- src/Encoder.php | 4 ++-- src/Exception/BadMethodCallException.php | 2 +- src/Exception/InvalidArgumentException.php | 2 +- src/Json.php | 23 ++++++++++--------- src/Server/Exception/ErrorException.php | 2 +- .../Exception/InvalidArgumentException.php | 2 +- src/Server/Exception/RuntimeException.php | 2 +- src/Server/Server.php | 4 ++-- test/JsonTest.php | 14 +++++------ test/JsonXmlTest.php | 4 ++-- test/Server/Smd/ServiceTest.php | 6 ++--- test/ServerTest.php | 4 ++-- 12 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/Encoder.php b/src/Encoder.php index eee9c116d..d8a998cef 100644 --- a/src/Encoder.php +++ b/src/Encoder.php @@ -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); } @@ -148,7 +148,7 @@ protected function _encodeObject(&$value) } $className = get_class($value); - return '{"__className":' + return '{"__className":' . $this->_encodeString($className) . $props . '}'; } diff --git a/src/Exception/BadMethodCallException.php b/src/Exception/BadMethodCallException.php index 1c8adb761..11d22c133 100644 --- a/src/Exception/BadMethodCallException.php +++ b/src/Exception/BadMethodCallException.php @@ -15,6 +15,6 @@ * @package Zend_Json * @subpackage Exception */ -class BadMethodCallException extends \BadMethodCallException implements +class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface {} diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php index 5eb27525f..f9aacec83 100644 --- a/src/Exception/InvalidArgumentException.php +++ b/src/Exception/InvalidArgumentException.php @@ -14,6 +14,6 @@ * @category Zend * @package Zend_Json */ -class InvalidArgumentException extends \InvalidArgumentException implements +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface {} diff --git a/src/Json.php b/src/Json.php index a62d3fcc7..68e0c9060 100644 --- a/src/Json.php +++ b/src/Json.php @@ -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(); @@ -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 ); } @@ -249,7 +249,7 @@ protected static function _processXml($simpleXmlElementObject, $ignoreXmlAttribu } if (!empty($value)) { $attributes['@text'] = $value; - } + } return array($name => $attributes); } @@ -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); @@ -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 @@ -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++; @@ -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 { diff --git a/src/Server/Exception/ErrorException.php b/src/Server/Exception/ErrorException.php index 23f98033b..1d5cf2288 100644 --- a/src/Server/Exception/ErrorException.php +++ b/src/Server/Exception/ErrorException.php @@ -19,6 +19,6 @@ * @package Zend_Json * @subpackage Server */ -class ErrorException extends Exception\BadMethodCallException implements +class ErrorException extends Exception\BadMethodCallException implements ExceptionInterface {} diff --git a/src/Server/Exception/InvalidArgumentException.php b/src/Server/Exception/InvalidArgumentException.php index 060d62be1..4593735f4 100644 --- a/src/Server/Exception/InvalidArgumentException.php +++ b/src/Server/Exception/InvalidArgumentException.php @@ -17,6 +17,6 @@ * @package Zend_Json * @subpackage Server */ -class InvalidArgumentException extends Exception\InvalidArgumentException implements +class InvalidArgumentException extends Exception\InvalidArgumentException implements ExceptionInterface {} diff --git a/src/Server/Exception/RuntimeException.php b/src/Server/Exception/RuntimeException.php index 88f7f8b8b..073630b32 100644 --- a/src/Server/Exception/RuntimeException.php +++ b/src/Server/Exception/RuntimeException.php @@ -17,6 +17,6 @@ * @package Zend_Json * @subpackage Server */ -class RuntimeException extends Exception\RuntimeException implements +class RuntimeException extends Exception\RuntimeException implements ExceptionInterface {} diff --git a/src/Server/Server.php b/src/Server/Server.php index 37ee0cfa3..e817cd680 100644 --- a/src/Server/Server.php +++ b/src/Server/Server.php @@ -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() ); diff --git a/test/JsonTest.php b/test/JsonTest.php index 01e20ba59..22250e617 100644 --- a/test/JsonTest.php +++ b/test/JsonTest.php @@ -732,7 +732,7 @@ public function testEncodeObjectImplementingIterator() { $this->markTestIncomplete('Test is not yet finished.'); } - + /** * @group ZF-8663 */ @@ -740,7 +740,7 @@ public function testNativeJSONEncoderWillProperlyEncodeSolidusInStringValues() { $source = "bar"; $target = '"\u003C\/foo\u003E\u003Cfoo\u003Ebar\u003C\/foo\u003E"'; - + // first test ext/json Json\Json::$useBuiltinEncoderDecoder = false; $this->assertEquals($target, Json\Json::encode($source)); @@ -750,12 +750,12 @@ 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 */ @@ -763,7 +763,7 @@ public function testBuiltinJSONEncoderWillProperlyEncodeSolidusInStringValues() { $source = "bar"; $target = '"\u003C\/foo\u003E\u003Cfoo\u003Ebar\u003C\/foo\u003E"'; - + // first test ext/json Json\Json::$useBuiltinEncoderDecoder = true; $this->assertEquals($target, Json\Json::encode($source)); @@ -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 */ diff --git a/test/JsonXmlTest.php b/test/JsonXmlTest.php index 07027336f..49d8c2a72 100644 --- a/test/JsonXmlTest.php +++ b/test/JsonXmlTest.php @@ -496,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 = << diff --git a/test/Server/Smd/ServiceTest.php b/test/Server/Smd/ServiceTest.php index 5bfc87a81..6457a4156 100644 --- a/test/Server/Smd/ServiceTest.php +++ b/test/Server/Smd/ServiceTest.php @@ -40,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'); @@ -58,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()); @@ -82,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'); diff --git a/test/ServerTest.php b/test/ServerTest.php index b86ce3b68..7efbd02f6 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -301,7 +301,7 @@ public function testHandleShouldAllowNamedParamsInAnyOrder1() ->setReturnResponse(true); $request = $this->server->getRequest(); $request->setMethod('bar') - ->setParams( array( + ->setParams( array( 'three' => 3, 'two' => 2, 'one' => 1 @@ -322,7 +322,7 @@ public function testHandleShouldAllowNamedParamsInAnyOrder2() ->setReturnResponse(true); $request = $this->server->getRequest(); $request->setMethod('bar') - ->setParams( array( + ->setParams( array( 'three' => 3, 'one' => 1, 'two' => 2,