Skip to content

Commit 9db90c6

Browse files
samdarkStyleCIBot
authored andcommitted
Apply fixes from StyleCI
1 parent e3abac2 commit 9db90c6

8 files changed

+26
-24
lines changed

src/Formatter/HtmlDataResponseFormatter.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
namespace Yiisoft\DataResponse\Formatter;
66

77
use Psr\Http\Message\ResponseInterface;
8-
use Yiisoft\DataResponse\HasContentTypeTrait;
9-
use Yiisoft\Http\Header;
108
use Yiisoft\DataResponse\DataResponse;
119
use Yiisoft\DataResponse\DataResponseFormatterInterface;
10+
use Yiisoft\DataResponse\HasContentTypeTrait;
11+
use Yiisoft\Http\Header;
1212

1313
final class HtmlDataResponseFormatter implements DataResponseFormatterInterface
1414
{
@@ -27,7 +27,7 @@ final class HtmlDataResponseFormatter implements DataResponseFormatterInterface
2727
public function format(DataResponse $dataResponse): ResponseInterface
2828
{
2929
$data = $dataResponse->getData();
30-
if (!is_scalar($data) && !is_null($data) && !$this->isStringableObject($data)) {
30+
if (!is_scalar($data) && null !== $data && !$this->isStringableObject($data)) {
3131
throw new \RuntimeException('Data must be a scalar value or null or a stringable object.');
3232
}
3333

src/Formatter/JsonDataResponseFormatter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
namespace Yiisoft\DataResponse\Formatter;
66

77
use Psr\Http\Message\ResponseInterface;
8+
use Yiisoft\DataResponse\DataResponse;
9+
use Yiisoft\DataResponse\DataResponseFormatterInterface;
810
use Yiisoft\DataResponse\HasContentTypeTrait;
911
use Yiisoft\Http\Header;
1012
use Yiisoft\Serializer\JsonSerializer;
11-
use Yiisoft\DataResponse\DataResponse;
12-
use Yiisoft\DataResponse\DataResponseFormatterInterface;
1313

1414
final class JsonDataResponseFormatter implements DataResponseFormatterInterface
1515
{

src/Formatter/XmlDataResponseFormatter.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
namespace Yiisoft\DataResponse\Formatter;
66

7+
use function is_array;
8+
use function is_float;
9+
use function is_scalar;
710
use Psr\Http\Message\ResponseInterface;
811
use Traversable;
12+
use Yiisoft\DataResponse\DataResponse;
13+
use Yiisoft\DataResponse\DataResponseFormatterInterface;
914
use Yiisoft\DataResponse\HasContentTypeTrait;
15+
1016
use Yiisoft\Http\Header;
1117
use Yiisoft\Serializer\XmlSerializer;
1218
use Yiisoft\Strings\NumericHelper;
13-
use Yiisoft\DataResponse\DataResponse;
14-
use Yiisoft\DataResponse\DataResponseFormatterInterface;
15-
16-
use function is_array;
17-
use function is_float;
18-
use function is_scalar;
1919

2020
final class XmlDataResponseFormatter implements DataResponseFormatterInterface
2121
{
@@ -80,6 +80,7 @@ public function withRootTag(string $rootTag): self
8080
* Pre-formats the data before serialization.
8181
*
8282
* @param mixed $data to format.
83+
*
8384
* @return mixed formatted data.
8485
*/
8586
private function formatData($data)
@@ -108,7 +109,8 @@ private function formatData($data)
108109
/**
109110
* Formats scalar value to use in XML node.
110111
*
111-
* @param int|string|bool|float $value to format.
112+
* @param bool|float|int|string $value to format.
113+
*
112114
* @return string string representation of the value.
113115
*/
114116
private function formatScalarValue($value): string

src/Middleware/FormatDataResponse.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
use Psr\Http\Message\ServerRequestInterface;
99
use Psr\Http\Server\MiddlewareInterface;
1010
use Psr\Http\Server\RequestHandlerInterface;
11-
use Yiisoft\DataResponse\DataResponseFormatterInterface;
1211
use Yiisoft\DataResponse\DataResponse;
12+
use Yiisoft\DataResponse\DataResponseFormatterInterface;
1313

1414
class FormatDataResponse implements MiddlewareInterface
1515
{

tests/DataResponseTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
use Nyholm\Psr7\Stream;
99
use PHPUnit\Framework\TestCase;
1010
use Psr\Http\Message\ResponseInterface;
11+
use Yiisoft\DataResponse\DataResponse;
1112
use Yiisoft\DataResponse\DataResponseFactory;
13+
use Yiisoft\DataResponse\Formatter\JsonDataResponseFormatter;
1214
use Yiisoft\DataResponse\Tests\Stub\LoopDataResponseFormatter;
1315
use Yiisoft\Http\Header;
1416
use Yiisoft\Http\Status;
15-
use Yiisoft\DataResponse\Formatter\JsonDataResponseFormatter;
16-
use Yiisoft\DataResponse\DataResponse;
1717

1818
class DataResponseTest extends TestCase
1919
{
@@ -199,7 +199,7 @@ public function testGetData(): void
199199
$dataResponse = $this->createFactory()->createResponse('test');
200200
$this->assertEquals('test', $dataResponse->getData());
201201

202-
$dataResponse = $this->createFactory()->createResponse(fn() => 'test2');
202+
$dataResponse = $this->createFactory()->createResponse(fn () => 'test2');
203203
$this->assertEquals('test2', $dataResponse->getData());
204204
}
205205

tests/Formatter/HtmlDataResponseFormatterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testDataWithNull(): void
6161

6262
public function testDataWithObject(): void
6363
{
64-
$data = new class {
64+
$data = new class() {
6565
public function __toString(): string
6666
{
6767
return 'test';

tests/Formatter/XmlDataResponseFormatterTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
use Nyholm\Psr7\Factory\Psr17Factory;
88
use PHPUnit\Framework\TestCase;
9+
use function preg_replace;
10+
use function sprintf;
911
use stdClass;
10-
use Yiisoft\DataResponse\DataResponseFactory;
11-
use Yiisoft\DataResponse\Formatter\XmlDataResponseFormatter;
1212
use Yiisoft\DataResponse\DataResponse;
1313

14-
use function preg_replace;
15-
use function sprintf;
14+
use Yiisoft\DataResponse\DataResponseFactory;
15+
use Yiisoft\DataResponse\Formatter\XmlDataResponseFormatter;
1616

1717
class XmlDataResponseFormatterTest extends TestCase
1818
{
@@ -107,7 +107,7 @@ public function testArrayValues(): void
107107
{
108108
$dataResponse = $this->createResponse([
109109
[100 => [], '200' => null],
110-
[1, 1.1, 'foo' => 'bar', true, false]
110+
[1, 1.1, 'foo' => 'bar', true, false],
111111
]);
112112
$result = (new XmlDataResponseFormatter())->format($dataResponse);
113113
$result->getBody()->rewind();
@@ -227,7 +227,7 @@ private function xml(string $data, string $version = '1.0', string $encoding = '
227227

228228
private function createDummyObject(string $string, int $int, float $float, array $array): object
229229
{
230-
return new class ($string, $int, $float, $array) {
230+
return new class($string, $int, $float, $array) {
231231
private string $string;
232232
private int $int;
233233
private float $float;

tests/Middleware/FormatDataResponseTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
use Psr\Http\Message\ResponseInterface;
1111
use Psr\Http\Message\ServerRequestInterface;
1212
use Psr\Http\Server\RequestHandlerInterface;
13+
use Yiisoft\DataResponse\DataResponse;
1314
use Yiisoft\DataResponse\DataResponseFactory;
1415
use Yiisoft\DataResponse\Formatter\HtmlDataResponseFormatter;
1516
use Yiisoft\DataResponse\Formatter\JsonDataResponseFormatter;
1617
use Yiisoft\DataResponse\Formatter\XmlDataResponseFormatter;
1718
use Yiisoft\DataResponse\Middleware\FormatDataResponse;
18-
use Yiisoft\DataResponse\DataResponse;
1919
use Yiisoft\DataResponse\Middleware\FormatDataResponseAsHtml;
2020
use Yiisoft\DataResponse\Middleware\FormatDataResponseAsJson;
2121
use Yiisoft\DataResponse\Middleware\FormatDataResponseAsXml;

0 commit comments

Comments
 (0)