Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot authored and razonyang committed Sep 24, 2022
1 parent 1291061 commit 63db648
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/EmitterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface EmitterInterface
* Emits a PSR-7 response.
*
* @param ResponseInterface $response
* @param bool $withoutBody
* @param bool $withoutBody
*/
public function emit(ResponseInterface $response, bool $withoutBody = false);
}
14 changes: 7 additions & 7 deletions src/ServerRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public function create(Request $request): ServerRequestInterface
$server['SCRIPT_NAME'] = $this->getScriptName();
$uri = $this->createUri($server);

$headers = $request->header??[];
$headers = $request->header ?? [];

$cookies = $request->cookie ?? [];
if ($cookies) {
$tmp= [];
$tmp = [];
foreach ($cookies as $name => $value) {
$tmp[] = sprintf("%s=%s", $name, $value);
$tmp[] = sprintf('%s=%s', $name, $value);
}
$headers['cookie'] = implode('; ', $tmp);
}
Expand All @@ -44,7 +44,7 @@ public function create(Request $request): ServerRequestInterface
$psrRequest = $psrRequest
->withQueryParams($queryParams)
->withCookieParams($cookies)
->withUploadedFiles($this->parseUploadedFiles($request->files??[]));
->withUploadedFiles($this->parseUploadedFiles($request->files ?? []));

return $psrRequest;
}
Expand All @@ -53,7 +53,7 @@ private function getScriptName(): string
{
global $argv;

return $argv[0]??'';
return $argv[0] ?? '';
}

private function createUri(array $server): UriInterface
Expand All @@ -67,7 +67,7 @@ private function createUri(array $server): UriInterface
}

if (isset($server['SERVER_PORT'])) {
$uri = $uri->withPort((int)$server['SERVER_PORT']);
$uri = $uri->withPort((int) $server['SERVER_PORT']);
} else {
$uri = $uri->withPort($uri->getScheme() === 'https' ? 443 : 80);
}
Expand All @@ -76,7 +76,7 @@ private function createUri(array $server): UriInterface
$parts = explode(':', $server['HTTP_HOST']);
$uri = count($parts) == 2
? $uri->withHost($parts[0])
->withPort((int)$parts[1])
->withPort((int) $parts[1])
: $uri->withHost($server['HTTP_HOST']);
} elseif (isset($server['SERVER_NAME'])) {
$uri = $uri->withHost($server['SERVER_NAME']);
Expand Down
6 changes: 3 additions & 3 deletions tests/EmitterFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public function newProvider(): array
return [
[
1024 * 1024,
2 * 1024* 1024,
4 * 1024* 1024,
8 * 1024* 1024,
2 * 1024 * 1024,
4 * 1024 * 1024,
8 * 1024 * 1024,
],
];
}
Expand Down
58 changes: 29 additions & 29 deletions tests/ServerRequestFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public function messageProvider(): array
'GET',
'/',
[
'Host' => ['localhost'],
'Connection' => ['keep-alive'],
'Pragma' => ['no-cache'],
'Cache-Control' => ['no-cache'],
'Accept' => ['text/html'],
'Host' => ['localhost'],
'Connection' => ['keep-alive'],
'Pragma' => ['no-cache'],
'Cache-Control' => ['no-cache'],
'Accept' => ['text/html'],
'Accept-Encoding' => ['gzip, deflate, br'],
'Cookie' => ['phpsessid=fcccs2af8673a2f343a61a96551c8523d79ea; username=razonyang'],
'Cookie' => ['phpsessid=fcccs2af8673a2f343a61a96551c8523d79ea; username=razonyang'],
],
null,
],
Expand All @@ -43,8 +43,8 @@ public function messageProvider(): array
'POST',
'/users',
[
'Host' => ['localhost'],
'Content-Type' => ['application/json'],
'Host' => ['localhost'],
'Content-Type' => ['application/json'],
'Content-Length' => ['23'],
],
'{"name":"bar","age":18}',
Expand All @@ -58,7 +58,7 @@ public function messageProvider(): array
null,
[
'foo.txt' => __FILE__,
'bar.txt' => \dirname(__DIR__) .\DIRECTORY_SEPARATOR . 'README.md',
'bar.txt' => \dirname(__DIR__).\DIRECTORY_SEPARATOR.'README.md',
],
],
];
Expand All @@ -82,7 +82,6 @@ public function testCreate(
}
}


$builder = (new RequestBuilder($method, $uri))
->headers($headers);

Expand Down Expand Up @@ -227,7 +226,7 @@ public function portProvider(): array
[
[
'SERVER_PORT' => 9501,
'HTTP_HOST' => 'localhost:9502',
'HTTP_HOST' => 'localhost:9502',
],
9502,
],
Expand Down Expand Up @@ -352,39 +351,40 @@ public function testParseProtocolVersion(string $protocol, string $version): voi
public function filesProvider(): array
{
$tmpDir = \sys_get_temp_dir();

return [
[
[],
],
[
[
'foo.jpg' => [
'name' => 'foo.jpg',
'type' => 'image/jpeg',
'tmp_name' => $tmpDir. \DIRECTORY_SEPARATOR. 'swoole.upfile.foo.jpg',
'error' => 0,
'size' => 7,
'content' => 'foo.jpg',
'name' => 'foo.jpg',
'type' => 'image/jpeg',
'tmp_name' => $tmpDir.\DIRECTORY_SEPARATOR.'swoole.upfile.foo.jpg',
'error' => 0,
'size' => 7,
'content' => 'foo.jpg',
],
],
],
[
[
'bar.png' => [
'name' => 'bar.png',
'type' => 'image/png',
'tmp_name' => $tmpDir. \DIRECTORY_SEPARATOR. 'swoole.upfile.bar.png',
'error' => 0,
'size' => 7,
'content' => 'bar.png',
'name' => 'bar.png',
'type' => 'image/png',
'tmp_name' => $tmpDir.\DIRECTORY_SEPARATOR.'swoole.upfile.bar.png',
'error' => 0,
'size' => 7,
'content' => 'bar.png',
],
'fizz.jpg' => [
'name' => 'fizz.jpg',
'type' => 'image/jpeg',
'tmp_name' => $tmpDir. \DIRECTORY_SEPARATOR. 'swoole.upfile.fizz.jpg',
'error' => 0,
'size' => 8,
'content' => 'fizz.jpg',
'name' => 'fizz.jpg',
'type' => 'image/jpeg',
'tmp_name' => $tmpDir.\DIRECTORY_SEPARATOR.'swoole.upfile.fizz.jpg',
'error' => 0,
'size' => 8,
'content' => 'fizz.jpg',
],
],
],
Expand Down

0 comments on commit 63db648

Please sign in to comment.