Skip to content

Commit 7b8bb0a

Browse files
committed
style: Use the latest v1.1.x code style standard
1 parent 7f59c9e commit 7b8bb0a

11 files changed

Lines changed: 123 additions & 36 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"require": {
1616
"php": ">=8.1",
1717
"ext-sockets": "*",
18-
"cloudtay/ripple": "^1.0.5",
18+
"cloudtay/ripple": "^1.0",
1919
"symfony/http-foundation": "*",
2020
"guzzlehttp/guzzle": "*"
2121
},

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function __construct(private readonly array $config = [])
5656
* @param array $option
5757
*
5858
* @return Response
59-
* @throws \Ripple\Stream\Exception\ConnectionException
59+
* @throws ConnectionException
6060
*/
6161
public function request(RequestInterface $request, array $option = []): Response
6262
{

src/Client/Capture.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ abstract public function onError(Throwable|Exception $exception): void;
4343
/**
4444
* 请求完成
4545
*
46-
* @param \GuzzleHttp\Psr7\Response $response
46+
* @param Response $response
4747
*
4848
* @return void
4949
*/

src/Client/Capture/ServerSentEvents.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Exception;
1717
use GuzzleHttp\Psr7\Response;
1818
use Iterator;
19+
use Ripple\Coroutine\Context;
1920
use Ripple\Coroutine\Coroutine;
2021
use Ripple\Http\Client\Capture;
2122
use Throwable;
@@ -34,10 +35,10 @@
3435
*/
3536
class ServerSentEvents extends Capture
3637
{
37-
/*** @var \Closure|null */
38+
/*** @var Closure|null */
3839
public Closure|null $onEvent = null;
3940

40-
/*** @var \Closure|null */
41+
/*** @var Closure|null */
4142
public Closure|null $onComplete = null;
4243

4344
/*** @var array */
@@ -86,7 +87,7 @@ public function onError(Throwable|Exception $exception): void
8687
}
8788

8889
/**
89-
* @param \GuzzleHttp\Psr7\Response $response
90+
* @param Response $response
9091
*
9192
* @return void
9293
*/
@@ -152,7 +153,7 @@ public function processContent(string $content): void
152153
public function getIterator(): iterable
153154
{
154155
return $this->iterators[] = new class ($this) implements Iterator {
155-
/*** @var \Ripple\Coroutine\Context[] */
156+
/*** @var Context[] */
156157

157158
protected array $waiters = [];
158159

src/Client/Connection.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
use function fwrite;
3535
use function hexdec;
3636
use function implode;
37-
use function intval;
3837
use function is_resource;
3938
use function strlen;
4039
use function strpos;
@@ -87,7 +86,7 @@ class Connection
8786
/*** @var mixed|null */
8887
private mixed $output = null;
8988

90-
/*** @var \Ripple\Http\Client\Capture|null */
89+
/*** @var Capture|null */
9190
private Capture|null $capture = null;
9291

9392
private WaitGroup $waitGroup;
@@ -129,12 +128,12 @@ private function reset(): void
129128
}
130129

131130
/**
132-
* @param \Psr\Http\Message\RequestInterface $request
131+
* @param RequestInterface $request
133132
* @param array $option
134133
*
135-
* @return \GuzzleHttp\Psr7\Response
136-
* @throws \Ripple\Stream\Exception\ConnectionException
137-
* @throws \Ripple\Stream\Exception\RuntimeException
134+
* @return Response
135+
* @throws ConnectionException
136+
* @throws RuntimeException
138137
*/
139138
public function request(RequestInterface $request, array $option = []): Response
140139
{
@@ -149,12 +148,12 @@ public function request(RequestInterface $request, array $option = []): Response
149148
}
150149

151150
/**
152-
* @param \Psr\Http\Message\RequestInterface $request
151+
* @param RequestInterface $request
153152
* @param array $option
154153
*
155-
* @return \GuzzleHttp\Psr7\Response
156-
* @throws \Ripple\Stream\Exception\ConnectionException
157-
* @throws \Ripple\Stream\Exception\RuntimeException
154+
* @return Response
155+
* @throws ConnectionException
156+
* @throws RuntimeException
158157
*/
159158
private function queue(RequestInterface $request, array $option = []): Response
160159
{
@@ -246,8 +245,6 @@ private function queue(RequestInterface $request, array $option = []): Response
246245
'Connection closed by peer',
247246
ConnectionException::CONNECTION_CLOSED,
248247
null,
249-
$this->stream,
250-
true
251248
);
252249
}
253250

@@ -302,7 +299,7 @@ public function tick(string|false $content): ResponseInterface|null
302299

303300
/**
304301
* @return ResponseInterface|null
305-
* @throws \Ripple\Stream\Exception\RuntimeException
302+
* @throws RuntimeException
306303
*/
307304
public function tickClose(): ResponseInterface|null
308305
{
@@ -319,8 +316,8 @@ public function tickClose(): ResponseInterface|null
319316
}
320317

321318
/**
322-
* @return \Psr\Http\Message\ResponseInterface|null
323-
* @throws \Ripple\Stream\Exception\RuntimeException
319+
* @return ResponseInterface|null
320+
* @throws RuntimeException
324321
*/
325322
public function process(): ResponseInterface|null
326323
{

src/Enum/Status.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,13 @@ public function getMessage(): string
156156
}
157157

158158
/**
159-
* 获取状态码对应的消息(使用状态码)
159+
* Obtaining the Message Corresponding to a Status Code (Using a Status Code)
160160
*
161-
* @param int $code 状态码
162-
* @return string|null 状态消息,不存在则返回null
161+
* @param int $code Status code
162+
* @return string|null Status message, null if it does not exist
163163
*/
164-
public static function getMessageForCode(int $code): ?string
164+
public static function getMessageForCode(int $code): string|null
165165
{
166-
return self::tryFrom($code)?->getMessage();
166+
return Status::tryFrom($code)?->getMessage();
167167
}
168168
}

src/Guzzle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function __construct()
4444
/**
4545
* @param array $config
4646
*
47-
* @return \GuzzleHttp\Client
47+
* @return Client
4848
*/
4949
public static function newClient(array $config = []): Client
5050
{

src/Guzzle/RippleHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
class RippleHandler
2727
{
2828
/**
29-
* @param \Ripple\Http\Client $httpClient
29+
* @param Client $httpClient
3030
*/
3131
public function __construct(private readonly Client $httpClient)
3232
{

src/Server.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Server
4545
*/
4646
public Closure $onRequest;
4747

48-
/*** @var \Ripple\Socket */
48+
/*** @var Socket */
4949
private Socket $server;
5050

5151
/**
@@ -122,7 +122,7 @@ public function listen(): void
122122
}
123123

124124
/**
125-
* @param \Ripple\Socket $stream
125+
* @param Socket $stream
126126
*
127127
* @return void
128128
*/
@@ -162,9 +162,9 @@ private function listenSocket(Socket $stream): void
162162
$stream->close();
163163
} catch (FormatException) {
164164
/**** The message format is illegal*/
165-
$response->setStatusCode(Status::BAD_REQUEST)->setBody(Status::MESSAGES[Status::BAD_REQUEST])->respond();
165+
$response->setStatusCode(Status::BAD_REQUEST->value)->setBody(Status::getMessageForCode(Status::BAD_REQUEST->value))->respond();
166166
} catch (Throwable $e) {
167-
$response->setStatusCode(Status::INTERNAL_SERVER_ERROR)->setBody($e->getMessage())->respond();
167+
$response->setStatusCode(Status::INTERNAL_SERVER_ERROR->value)->setBody($e->getMessage())->respond();
168168
Output::exception($e);
169169
}
170170
});

src/Server/Connection.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use function array_merge;
2525
use function count;
2626
use function explode;
27-
use function intval;
2827
use function is_array;
2928
use function is_string;
3029
use function json_decode;

0 commit comments

Comments
 (0)