Skip to content

Commit 0c4722a

Browse files
Cleanup the @throws code comments (#2916)
1 parent ea64601 commit 0c4722a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+440
-1081
lines changed

docs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
"preinstall": "npx only-allow pnpm"
99
},
1010
"dependencies": {
11-
"autoprefixer": "^10.4.20",
11+
"autoprefixer": "^10.4.21",
1212
"clipboard": "^2.0.11",
1313
"dynamics.js": "^1.1.5",
1414
"gsap": "^3.12.7",
1515
"tailwindcss": "^3.4.17"
1616
},
1717
"devDependencies": {
1818
"@types/markdown-it": "^14.1.2",
19-
"@types/node": "^22.13.7",
19+
"@types/node": "^22.13.14",
2020
"postcss": "^8.5.3",
2121
"postcss-import": "^16.1.0",
2222
"tenyun": "^0.12.0",

docs/pnpm-lock.yaml

+286-277
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Kernel/Contracts/Server.php

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
use Psr\Http\Message\ResponseInterface;
88

9+
/**
10+
* @method mixed withDefaultSuiteTicketHandler(callable $handler) used in \EasyWeChat\OpenWork\Server
11+
*/
912
interface Server
1013
{
1114
public function serve(): ResponseInterface;

src/Kernel/Encryptor.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ public function encrypt(string $plaintext, ?string $nonce = null, int|string|nul
9292
return $this->encryptAsXml($plaintext, $nonce, $timestamp);
9393
}
9494

95-
/**
96-
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
97-
*/
9895
public function encryptAsXml(string $plaintext, ?string $nonce = null, int|string|null $timestamp = null): string
9996
{
10097
$encrypted = $this->encryptAsArray($plaintext, $nonce, $timestamp);
@@ -110,7 +107,7 @@ public function encryptAsXml(string $plaintext, ?string $nonce = null, int|strin
110107
}
111108

112109
/**
113-
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
110+
* @throws RuntimeException
114111
*/
115112
public function encryptAsArray(string $plaintext, ?string $nonce = null, int|string|null $timestamp = null): array
116113
{

src/Kernel/Form/File.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static function from(
3434
}
3535

3636
/**
37-
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
37+
* @throws RuntimeException
3838
*/
3939
public static function fromContents(
4040
string $contents,

src/Kernel/HttpClient/AccessTokenAwareClient.php

-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Symfony\Component\HttpClient\AsyncDecoratorTrait;
1212
use Symfony\Component\HttpClient\HttpClient;
1313
use Symfony\Component\HttpClient\MockHttpClient;
14-
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
1514
use Symfony\Contracts\HttpClient\HttpClientInterface;
1615

1716
use function array_merge;
@@ -49,8 +48,6 @@ public function withAccessToken(AccessTokenInterface $accessToken): static
4948

5049
/**
5150
* @param array<string, mixed> $options
52-
*
53-
* @throws TransportExceptionInterface
5451
*/
5552
public function request(string $method, string $url, array $options = []): Response
5653
{

src/Kernel/HttpClient/RequestUtil.php

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ public static function formatOptions(array $options, string $method): array
106106
/**
107107
* @param array{headers?:array<string, string>, xml?:mixed, body?:array|string, json?:mixed} $options
108108
* @return array{headers?:array<string, string|array<string, string>|array<string>>, xml?:array|string, body?:array|string}
109+
*
110+
* @throws InvalidArgumentException
109111
*/
110112
public static function formatBody(array $options): array
111113
{

src/Kernel/HttpClient/Response.php

+3-85
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
use Symfony\Component\HttpClient\Response\MockResponse;
2020
use Symfony\Component\HttpClient\Response\StreamableInterface;
2121
use Symfony\Component\HttpClient\Response\StreamWrapper;
22-
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
23-
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
24-
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
25-
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
26-
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
2722
use Symfony\Contracts\HttpClient\ResponseInterface;
2823
use Throwable;
2924

@@ -74,23 +69,11 @@ public function judgeFailureUsing(callable $callback): static
7469
return $this;
7570
}
7671

77-
/**
78-
* @throws TransportExceptionInterface
79-
* @throws ServerExceptionInterface
80-
* @throws RedirectionExceptionInterface
81-
* @throws ClientExceptionInterface
82-
*/
8372
public function isSuccessful(): bool
8473
{
8574
return ! $this->isFailed();
8675
}
8776

88-
/**
89-
* @throws TransportExceptionInterface
90-
* @throws ServerExceptionInterface
91-
* @throws RedirectionExceptionInterface
92-
* @throws ClientExceptionInterface
93-
*/
9477
public function isFailed(): bool
9578
{
9679
if ($this->is('text') && $this->failureJudge) {
@@ -105,11 +88,6 @@ public function isFailed(): bool
10588
}
10689

10790
/**
108-
* @throws TransportExceptionInterface
109-
* @throws ServerExceptionInterface
110-
* @throws RedirectionExceptionInterface
111-
* @throws DecodingExceptionInterface
112-
* @throws ClientExceptionInterface
11391
* @throws BadResponseException
11492
*/
11593
public function toArray(?bool $throw = null): array
@@ -135,21 +113,15 @@ public function toArray(?bool $throw = null): array
135113
return $this->response->toArray($throw);
136114
}
137115

138-
/**
139-
* @throws TransportExceptionInterface
140-
* @throws ServerExceptionInterface
141-
* @throws RedirectionExceptionInterface
142-
* @throws DecodingExceptionInterface
143-
* @throws ClientExceptionInterface
144-
* @throws BadResponseException
145-
*/
146116
public function toJson(?bool $throw = null): string|false
147117
{
148118
return json_encode($this->toArray($throw), JSON_UNESCAPED_UNICODE);
149119
}
150120

151121
/**
152122
* {@inheritdoc}
123+
*
124+
* @throws BadMethodCallException
153125
*/
154126
public function toStream(?bool $throw = null)
155127
{
@@ -165,10 +137,7 @@ public function toStream(?bool $throw = null)
165137
}
166138

167139
/**
168-
* @throws TransportExceptionInterface
169-
* @throws ServerExceptionInterface
170-
* @throws RedirectionExceptionInterface
171-
* @throws ClientExceptionInterface
140+
* @throws \LogicException
172141
*/
173142
public function toDataUrl(): string
174143
{
@@ -214,10 +183,6 @@ public function toPsrResponse(?ResponseFactoryInterface $responseFactory = null,
214183
}
215184

216185
/**
217-
* @throws ClientExceptionInterface
218-
* @throws RedirectionExceptionInterface
219-
* @throws ServerExceptionInterface
220-
* @throws TransportExceptionInterface
221186
* @throws BadResponseException
222187
*/
223188
public function saveAs(string $filename): string
@@ -235,27 +200,11 @@ public function saveAs(string $filename): string
235200
return '';
236201
}
237202

238-
/**
239-
* @throws TransportExceptionInterface
240-
* @throws ServerExceptionInterface
241-
* @throws RedirectionExceptionInterface
242-
* @throws DecodingExceptionInterface
243-
* @throws ClientExceptionInterface
244-
* @throws BadResponseException
245-
*/
246203
public function offsetExists(mixed $offset): bool
247204
{
248205
return array_key_exists($offset, $this->toArray());
249206
}
250207

251-
/**
252-
* @throws TransportExceptionInterface
253-
* @throws ServerExceptionInterface
254-
* @throws RedirectionExceptionInterface
255-
* @throws DecodingExceptionInterface
256-
* @throws ClientExceptionInterface
257-
* @throws BadResponseException
258-
*/
259208
public function offsetGet(mixed $offset): mixed
260209
{
261210
return $this->toArray()[$offset] ?? null;
@@ -310,37 +259,18 @@ public function getInfo(?string $type = null): mixed
310259
return $this->response->getInfo($type);
311260
}
312261

313-
/**
314-
* @throws TransportExceptionInterface
315-
* @throws ServerExceptionInterface
316-
* @throws RedirectionExceptionInterface
317-
* @throws DecodingExceptionInterface
318-
* @throws ClientExceptionInterface
319-
* @throws BadResponseException
320-
*/
321262
public function __toString(): string
322263
{
323264
return $this->toJson() ?: '';
324265
}
325266

326-
/**
327-
* @throws TransportExceptionInterface
328-
* @throws ServerExceptionInterface
329-
* @throws RedirectionExceptionInterface
330-
* @throws ClientExceptionInterface
331-
*/
332267
public function hasHeader(string $name, ?bool $throw = null): bool
333268
{
334269
return isset($this->getHeaders($throw)[$name]);
335270
}
336271

337272
/**
338273
* @return array<array-key, mixed>
339-
*
340-
* @throws TransportExceptionInterface
341-
* @throws ServerExceptionInterface
342-
* @throws RedirectionExceptionInterface
343-
* @throws ClientExceptionInterface
344274
*/
345275
public function getHeader(string $name, ?bool $throw = null): array
346276
{
@@ -350,12 +280,6 @@ public function getHeader(string $name, ?bool $throw = null): array
350280
return $this->hasHeader($name, $throw) ? $this->getHeaders($throw)[$name] : [];
351281
}
352282

353-
/**
354-
* @throws TransportExceptionInterface
355-
* @throws ServerExceptionInterface
356-
* @throws RedirectionExceptionInterface
357-
* @throws ClientExceptionInterface
358-
*/
359283
public function getHeaderLine(string $name, ?bool $throw = null): string
360284
{
361285
$name = strtolower($name);
@@ -364,12 +288,6 @@ public function getHeaderLine(string $name, ?bool $throw = null): string
364288
return $this->hasHeader($name, $throw) ? implode(',', $this->getHeader($name, $throw)) : '';
365289
}
366290

367-
/**
368-
* @throws TransportExceptionInterface
369-
* @throws ServerExceptionInterface
370-
* @throws RedirectionExceptionInterface
371-
* @throws ClientExceptionInterface
372-
*/
373291
public function is(string $type): bool
374292
{
375293
$contentType = $this->getHeaderLine('content-type');

src/Kernel/Support/AesCbc.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class AesCbc implements Aes
1515
{
1616
/**
17-
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
17+
* @throws InvalidArgumentException
1818
*/
1919
public static function encrypt(string $plaintext, string $key, ?string $iv = null): string
2020
{
@@ -28,7 +28,7 @@ public static function encrypt(string $plaintext, string $key, ?string $iv = nul
2828
}
2929

3030
/**
31-
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
31+
* @throws InvalidArgumentException
3232
*/
3333
public static function decrypt(string $ciphertext, string $key, ?string $iv = null): string
3434
{

src/Kernel/Support/AesEcb.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class AesEcb implements Aes
1515
{
1616
/**
17-
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
17+
* @throws InvalidArgumentException
1818
*/
1919
public static function encrypt(string $plaintext, string $key, ?string $iv = null): string
2020
{
@@ -28,7 +28,7 @@ public static function encrypt(string $plaintext, string $key, ?string $iv = nul
2828
}
2929

3030
/**
31-
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
31+
* @throws InvalidArgumentException
3232
*/
3333
public static function decrypt(string $ciphertext, string $key, ?string $iv = null): string
3434
{

src/Kernel/Traits/InteractWithConfig.php

-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use EasyWeChat\Kernel\Config;
88
use EasyWeChat\Kernel\Contracts\Config as ConfigInterface;
9-
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
109

1110
use function is_array;
1211

@@ -16,8 +15,6 @@ trait InteractWithConfig
1615

1716
/**
1817
* @param array<string,mixed>|ConfigInterface $config
19-
*
20-
* @throws InvalidArgumentException
2118
*/
2219
public function __construct(array|ConfigInterface $config)
2320
{

src/Kernel/Traits/InteractWithHandlers.php

-20
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ public function getHandlers(): array
3434
return $this->handlers;
3535
}
3636

37-
/**
38-
* @throws InvalidArgumentException
39-
*/
4037
public function with(callable|string $handler): static
4138
{
4239
return $this->withHandler($handler);
@@ -54,8 +51,6 @@ public function withHandler(callable|string $handler): static
5451

5552
/**
5653
* @return array{hash: string, handler: callable}
57-
*
58-
* @throws InvalidArgumentException
5954
*/
6055
#[ArrayShape(['hash' => 'string', 'handler' => 'callable'])]
6156
public function createHandlerItem(callable|string $handler): array
@@ -103,17 +98,11 @@ protected function makeClosure(callable|string $handler): callable
10398
throw new InvalidArgumentException(sprintf('Invalid handler: %s.', $handler));
10499
}
105100

106-
/**
107-
* @throws InvalidArgumentException
108-
*/
109101
public function prepend(callable|string $handler): static
110102
{
111103
return $this->prependHandler($handler);
112104
}
113105

114-
/**
115-
* @throws InvalidArgumentException
116-
*/
117106
public function prependHandler(callable|string $handler): static
118107
{
119108
array_unshift($this->handlers, $this->createHandlerItem($handler));
@@ -143,9 +132,6 @@ public function withoutHandler(callable|string $handler): static
143132
return $this;
144133
}
145134

146-
/**
147-
* @throws InvalidArgumentException
148-
*/
149135
public function indexOf(callable|string $handler): int
150136
{
151137
foreach ($this->handlers as $index => $item) {
@@ -157,9 +143,6 @@ public function indexOf(callable|string $handler): int
157143
return -1;
158144
}
159145

160-
/**
161-
* @throws InvalidArgumentException
162-
*/
163146
public function when(mixed $value, callable|string $handler): static
164147
{
165148
if (is_callable($value)) {
@@ -184,9 +167,6 @@ public function handle(mixed $result, mixed $payload = null): mixed
184167
return $next($payload);
185168
}
186169

187-
/**
188-
* @throws InvalidArgumentException
189-
*/
190170
public function has(callable|string $handler): bool
191171
{
192172
return $this->indexOf($handler) > -1;

0 commit comments

Comments
 (0)