1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-03 11:47:38 +02:00

CS fixes, refs #683

This commit is contained in:
Jordi Boggiano
2015-11-18 17:53:15 +00:00
parent 9532e979b6
commit 0178fd4f09
3 changed files with 13 additions and 12 deletions

View File

@@ -143,8 +143,8 @@ class NormalizerFormatter implements FormatterInterface
* *
* @param mixed $data * @param mixed $data
* @param bool $ignoreErrors * @param bool $ignoreErrors
* @return string
* @throws \RuntimeException if encoding fails and errors are not ignored * @throws \RuntimeException if encoding fails and errors are not ignored
* @return string
*/ */
protected function toJson($data, $ignoreErrors = false) protected function toJson($data, $ignoreErrors = false)
{ {
@@ -185,8 +185,8 @@ class NormalizerFormatter implements FormatterInterface
* *
* @param int $code return code of json_last_error function * @param int $code return code of json_last_error function
* @param mixed $data data that was meant to be encoded * @param mixed $data data that was meant to be encoded
* @return string JSON encoded data after error correction
* @throws \RuntimeException if failure can't be corrected * @throws \RuntimeException if failure can't be corrected
* @return string JSON encoded data after error correction
*/ */
private function handleJsonError($code, $data) private function handleJsonError($code, $data)
{ {
@@ -196,10 +196,8 @@ class NormalizerFormatter implements FormatterInterface
if (is_string($data)) { if (is_string($data)) {
$this->detectAndCleanUtf8($data); $this->detectAndCleanUtf8($data);
} elseif (is_array($data)) { } elseif (is_array($data)) {
array_walk_recursive($data, array($this, 'detectAndCleanUtf8')); array_walk_recursive($data, array($this, 'detectAndCleanUtf8'));
} else { } else {
$this->throwEncodeError($code, $data); $this->throwEncodeError($code, $data);
} }
@@ -256,7 +254,7 @@ class NormalizerFormatter implements FormatterInterface
* can be used as a callback for array_walk_recursive. * can be used as a callback for array_walk_recursive.
* *
* @param mixed &$data Input to check and convert if needed * @param mixed &$data Input to check and convert if needed
* @access private * @private
*/ */
public function detectAndCleanUtf8(&$data) public function detectAndCleanUtf8(&$data)
{ {

View File

@@ -18,6 +18,7 @@ class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
public function tearDown() public function tearDown()
{ {
\PHPUnit_Framework_Error_Warning::$enabled = true; \PHPUnit_Framework_Error_Warning::$enabled = true;
return parent::tearDown(); return parent::tearDown();
} }

View File

@@ -19,6 +19,7 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
public function tearDown() public function tearDown()
{ {
\PHPUnit_Framework_Error_Warning::$enabled = true; \PHPUnit_Framework_Error_Warning::$enabled = true;
return parent::tearDown(); return parent::tearDown();
} }
@@ -248,6 +249,7 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
public function providesDetectAndCleanUtf8() public function providesDetectAndCleanUtf8()
{ {
$obj = new \stdClass; $obj = new \stdClass;
return array( return array(
'null' => array(null, null), 'null' => array(null, null),
'int' => array(123, 123), 'int' => array(123, 123),