Skip to content

Commit 699298a

Browse files
committed
PHP 8.4 compatibility: explicit nullables
1 parent d29b568 commit 699298a

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

src/Github/Api.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ class Api
2727
private ?OAuth\Token $token = null;
2828

2929

30-
public function __construct(Http\IClient $client = null)
30+
public function __construct(?Http\IClient $client = null)
3131
{
3232
$this->client = $client ?: Helpers::createDefaultClient();
3333
}
3434

3535

36-
public function setToken(OAuth\Token $token = null): static
36+
public function setToken(?OAuth\Token $token = null): static
3737
{
3838
$this->token = $token;
3939
return $this;
@@ -46,7 +46,7 @@ public function getToken(): ?OAuth\Token
4646
}
4747

4848

49-
public function setDefaultParameters(array $defaults = null): static
49+
public function setDefaultParameters(?array $defaults = null): static
5050
{
5151
$this->defaultParameters = $defaults ?: [];
5252
return $this;
@@ -189,7 +189,7 @@ public function request(Http\Request $request): Http\Response
189189
* @throws MissingParameterException when substitution is used in URL but parameter is missing
190190
* @throws JsonException when encoding to JSON fails
191191
*/
192-
public function createRequest(string $method, string $urlPath, array $parameters = [], array $headers = [], string|array|object $content = null): Http\Request
192+
public function createRequest(string $method, string $urlPath, array $parameters = [], array $headers = [], string|array|object|null $content = null): Http\Request
193193
{
194194
if (stripos($urlPath, $this->url) === 0) { # Allows non-HTTPS URLs
195195
$baseUrl = $this->url;
@@ -225,7 +225,7 @@ public function createRequest(string $method, string $urlPath, array $parameters
225225
*
226226
* @throws ApiException
227227
*/
228-
public function decode(Http\Response $response, array $okCodes = null): mixed
228+
public function decode(Http\Response $response, ?array $okCodes = null): mixed
229229
{
230230
$content = $response->getContent();
231231
if (preg_match('~application/json~i', $response->getHeader('Content-Type', ''))) {
@@ -460,7 +460,7 @@ private function prefix(array $flags, string $name, string $value): string
460460
}
461461

462462

463-
private function escape(array $flags, string|int|false $value, int $maxLength = null): string
463+
private function escape(array $flags, string|int|false $value, ?int $maxLength = null): string
464464
{
465465
$value = (string) $value;
466466

src/Github/Http/CachedClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CachedClient implements IClient
2828
*/
2929
public function __construct(
3030
private Storages\ICache $cache,
31-
IClient $client = null,
31+
?IClient $client = null,
3232
private bool $forbidRecheck = false,
3333
) {
3434
$this->client = $client ?: Github\Helpers::createDefaultClient();

src/Github/Http/Message.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function hasHeader(string $name): bool
3535
}
3636

3737

38-
public function getHeader(string $name, string $default = null): ?string
38+
public function getHeader(string $name, ?string $default = null): ?string
3939
{
4040
$name = strtolower($name);
4141
return array_key_exists($name, $this->headers)

src/Github/Http/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(
2626
private string $method,
2727
private string $url,
2828
array $headers = [],
29-
string $content = null
29+
?string $content = null
3030
) {
3131
parent::__construct($headers, $content);
3232
}

src/Github/Http/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getPrevious(): ?Response
6363
/**
6464
* @throws Github\LogicException
6565
*/
66-
public function setPrevious(Response $previous = null): static
66+
public function setPrevious(?Response $previous = null): static
6767
{
6868
if ($this->previous) {
6969
throw new Github\LogicException('Previous response is already set.');

src/Github/OAuth/Login.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class Login
2929

3030
public function __construct(
3131
private Configuration $conf,
32-
Storages\ISessionStorage $storage = null,
33-
Http\IClient $client = null
32+
?Storages\ISessionStorage $storage = null,
33+
?Http\IClient $client = null
3434
) {
3535
$this->storage = $storage ?: new Storages\SessionStorage;
3636
$this->client = $client ?: Github\Helpers::createDefaultClient();
@@ -47,7 +47,7 @@ public function getClient(): Http\IClient
4747
* @param string $backUrl URL to redirect back from GitHub when user approves the permissions request
4848
* @param ?callable $redirectCb makes HTTP redirect to GitHub
4949
*/
50-
public function askPermissions(string $backUrl, callable $redirectCb = null): void
50+
public function askPermissions(string $backUrl, ?callable $redirectCb = null): void
5151
{
5252
/** @todo Something more safe? */
5353
$state = sha1(uniqid((string) microtime(true), true));

src/Github/exceptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ abstract class ApiException extends RuntimeException
4949
private ?Http\Response $response;
5050

5151

52-
public function __construct(string $message = '', int $code = 0, \Exception $previous = null, Http\Response $response = null)
52+
public function __construct(string $message = '', int $code = 0, ?\Exception $previous = null, ?Http\Response $response = null)
5353
{
5454
parent::__construct($message, $code, $previous);
5555
$this->response = clone $response;

0 commit comments

Comments
 (0)