Skip to content

Commit cbfce01

Browse files
author
A1rPun
committed
lint: fix stan/unit/csfixer
1 parent fb16ead commit cbfce01

File tree

70 files changed

+307
-2051
lines changed

Some content is hidden

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

70 files changed

+307
-2051
lines changed

phpstan-baseline.neon

+104-1,246
Large diffs are not rendered by default.

src/Client.php

+18-50
Original file line numberDiff line numberDiff line change
@@ -65,30 +65,24 @@ class Client implements ClientInterface, LoggerAwareInterface
6565
/**
6666
* Logger interface to use for log messages.
6767
*
68-
* @var LoggerInterface|NullLogger|null
68+
* @var LoggerInterface|NullLogger
6969
*/
7070
public LoggerInterface $logger;
7171

7272
protected HttpClient $client;
7373

7474
/**
7575
* The DNS Made Easy API Key.
76-
*
77-
* @var string
7876
*/
7977
protected string $apiKey;
8078

8179
/**
8280
* The DNS Made Easy Secret Key.
83-
*
84-
* @var string
8581
*/
8682
protected string $secretKey;
8783

8884
/**
8985
* The DNS Made Easy API Endpoint.
90-
*
91-
* @var string
9286
*/
9387
protected string $endpoint = 'https://api.dnsmadeeasy.com/V2.0';
9488

@@ -102,14 +96,14 @@ class Client implements ClientInterface, LoggerAwareInterface
10296
/**
10397
* A cache of instantiated manager classes.
10498
*
105-
* @var array
99+
* @var mixed[]
106100
*/
107101
protected array $managers = [];
108102

109103
/**
110104
* A map of manager names to classes.
111105
*
112-
* @var array|string[]
106+
* @var string[]
113107
*/
114108
protected array $managerMap = [
115109
'contactlists' => ContactListManager::class,
@@ -126,22 +120,16 @@ class Client implements ClientInterface, LoggerAwareInterface
126120

127121
/**
128122
* The ID of the last request to the API.
129-
*
130-
* @var string|null
131123
*/
132124
protected ?string $requestId = null;
133125

134126
/**
135127
* The request limit on the API.
136-
*
137-
* @var int|null
138128
*/
139129
protected ?int $requestLimit = null;
140130

141131
/**
142132
* The number of requests remaining until the limit is hit.
143-
*
144-
* @var int|null
145133
*/
146134
protected ?int $requestsRemaining = null;
147135

@@ -166,10 +154,10 @@ public function __construct(?HttpClient $client = null, ?PaginatorFactoryInterfa
166154
$this->logger = $logger;
167155
}
168156

169-
public function __get($name)
157+
public function __get(string $name): mixed
170158
{
171159
// Usage is a special manager and not like the others.
172-
if ($name == 'usage') {
160+
if ($name === 'usage') {
173161
if (! isset($this->managers['usage'])) {
174162
$this->managers['usage'] = new UsageManager($this);
175163
}
@@ -179,7 +167,7 @@ public function __get($name)
179167
return $this->getManager($name);
180168
}
181169

182-
public function setLogger(LoggerInterface $logger)
170+
public function setLogger(LoggerInterface $logger): void
183171
{
184172
$this->logger = $logger;
185173
}
@@ -244,10 +232,10 @@ public function getPaginatorFactory(): PaginatorFactoryInterface
244232
return $this->paginatorFactory;
245233
}
246234

247-
public function get(string $url, array $params = []): ResponseInterface
235+
public function get(string $url, ?array $params = null): ResponseInterface
248236
{
249237
$queryString = '';
250-
if ($params) {
238+
if ($params !== null) {
251239
$queryString = '?' . http_build_query($params);
252240
}
253241
$url .= $queryString;
@@ -256,28 +244,28 @@ public function get(string $url, array $params = []): ResponseInterface
256244
return $this->send($request);
257245
}
258246

259-
public function post(string $url, $payload): ResponseInterface
247+
public function post(string $url, mixed $payload): ResponseInterface
260248
{
261249
$request = new Request('POST', $this->endpoint . $url, [], 'php://temp');
262250
$request->withHeader('Content-Type', 'application/json');
263-
$request->getBody()->write(json_encode($payload));
251+
$request->getBody()->write(json_encode($payload, JSON_THROW_ON_ERROR));
264252
return $this->send($request);
265253
}
266254

267-
public function put(string $url, $payload): ResponseInterface
255+
public function put(string $url, mixed $payload): ResponseInterface
268256
{
269257
$request = new Request('PUT', $this->endpoint . $url, [], 'php://temp');
270258
$request->withHeader('Content-Type', 'application/json');
271-
$request->getBody()->write(json_encode($payload));
259+
$request->getBody()->write(json_encode($payload, JSON_THROW_ON_ERROR));
272260
return $this->send($request);
273261
}
274262

275-
public function delete(string $url, $payload = null): ResponseInterface
263+
public function delete(string $url, mixed $payload = null): ResponseInterface
276264
{
277265
$request = new Request('DELETE', $this->endpoint . $url);
278-
if ($payload) {
266+
if ($payload !== null) {
279267
$request->withHeader('Content-Type', 'application/json');
280-
$request->getBody()->write(json_encode($payload));
268+
$request->getBody()->write(json_encode($payload, JSON_THROW_ON_ERROR));
281269
}
282270
return $this->send($request);
283271
}
@@ -313,8 +301,6 @@ public function send(RequestInterface $request): ResponseInterface
313301

314302
/**
315303
* Return the ID of the last API request.
316-
*
317-
* @return string|null
318304
*/
319305
public function getLastRequestId(): ?string
320306
{
@@ -323,8 +309,6 @@ public function getLastRequestId(): ?string
323309

324310
/**
325311
* Get the request limit.
326-
*
327-
* @return int|null
328312
*/
329313
public function getRequestLimit(): ?int
330314
{
@@ -333,8 +317,6 @@ public function getRequestLimit(): ?int
333317

334318
/**
335319
* Get the number of requests remaining before you hit the request limit.
336-
*
337-
* @return int|null
338320
*/
339321
public function getRequestsRemaining(): ?int
340322
{
@@ -343,10 +325,8 @@ public function getRequestsRemaining(): ?int
343325

344326
/**
345327
* Fetch the API request details from the last API response.
346-
*
347-
* @param ResponseInterface $response
348328
*/
349-
protected function updateLimits(ResponseInterface $response)
329+
protected function updateLimits(ResponseInterface $response): void
350330
{
351331
$requestId = current($response->getHeader('x-dnsme-requestId'));
352332
if ($requestId === false) {
@@ -373,11 +353,7 @@ protected function updateLimits(ResponseInterface $response)
373353
/**
374354
* Adds auth headers to requests. These are generated based on the Api Key and the Secret Key.
375355
*
376-
* @param RequestInterface $request
377-
*
378356
* @throws \Exception
379-
*
380-
* @return RequestInterface
381357
*/
382358
protected function addAuthHeaders(RequestInterface $request): RequestInterface
383359
{
@@ -393,12 +369,8 @@ protected function addAuthHeaders(RequestInterface $request): RequestInterface
393369

394370
/**
395371
* Check if a manager exists with that name in our manager map.
396-
*
397-
* @param $name
398-
*
399-
* @return bool
400372
*/
401-
protected function hasManager($name): bool
373+
protected function hasManager(string $name): bool
402374
{
403375
$name = strtolower($name);
404376
return array_key_exists($name, $this->managerMap);
@@ -407,13 +379,9 @@ protected function hasManager($name): bool
407379
/**
408380
* Gets the manager with the specified name.
409381
*
410-
* @param $name
411-
*
412382
* @throws ManagerNotFoundException
413-
*
414-
* @return AbstractManagerInterface
415383
*/
416-
protected function getManager($name): AbstractManagerInterface
384+
protected function getManager(string $name): AbstractManagerInterface
417385
{
418386
if (! $this->hasManager($name)) {
419387
throw new ManagerNotFoundException();

src/Exceptions/Client/Http/HttpException.php

+2-14
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,24 @@ class HttpException extends DnsMadeEasyException
1717
{
1818
/**
1919
* The request that was made when the exception was thrown.
20-
*
21-
* @var RequestInterface|null
2220
*/
2321
protected ?RequestInterface $request = null;
2422

2523
/**
2624
* The response to the request.
27-
*
28-
* @var ResponseInterface|null
2925
*/
3026
protected ?ResponseInterface $response = null;
3127

3228
/**
3329
* Set the request that caused the exception.
34-
*
35-
* @param RequestInterface $request
3630
*/
37-
public function setRequest(RequestInterface $request)
31+
public function setRequest(RequestInterface $request): void
3832
{
3933
$this->request = $request;
4034
}
4135

4236
/**
4337
* Get the request that caused the exception.
44-
*
45-
* @return RequestInterface|null
4638
*/
4739
public function getRequest(): ?RequestInterface
4840
{
@@ -51,18 +43,14 @@ public function getRequest(): ?RequestInterface
5143

5244
/**
5345
* Set the response that caused the exception.
54-
*
55-
* @param ResponseInterface $response
5646
*/
57-
public function setResponse(ResponseInterface $response)
47+
public function setResponse(ResponseInterface $response): void
5848
{
5949
$this->response = $response;
6050
}
6151

6252
/**
6353
* Get the response that caused the exception.
64-
*
65-
* @return ResponseInterface|null
6654
*/
6755
public function getResponse(): ?ResponseInterface
6856
{

0 commit comments

Comments
 (0)