diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 63a6baa..9a4dd90 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,11 +8,11 @@ jobs: strategy: fail-fast: false matrix: - php: [8.0, 8.1, 8.2] + php: [8.0, 8.1, 8.2, 8.3, 8.4] name: PHP ${{ matrix.php }} tests steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} @@ -21,7 +21,7 @@ jobs: - run: composer install --no-progress --prefer-dist - run: vendor/bin/tester tests -s - if: failure() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: output path: tests/**/output diff --git a/composer.json b/composer.json index 199b874..1d8b8b0 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": ">=8.0 <8.3" + "php": ">=8.0 <8.5" }, "require-dev": { "nette/tester": "^2.4" diff --git a/src/Github/Api.php b/src/Github/Api.php index a874a83..94a0613 100644 --- a/src/Github/Api.php +++ b/src/Github/Api.php @@ -27,13 +27,13 @@ class Api private ?OAuth\Token $token = null; - public function __construct(Http\IClient $client = null) + public function __construct(?Http\IClient $client = null) { $this->client = $client ?: Helpers::createDefaultClient(); } - public function setToken(OAuth\Token $token = null): static + public function setToken(?OAuth\Token $token = null): static { $this->token = $token; return $this; @@ -46,7 +46,7 @@ public function getToken(): ?OAuth\Token } - public function setDefaultParameters(array $defaults = null): static + public function setDefaultParameters(?array $defaults = null): static { $this->defaultParameters = $defaults ?: []; return $this; @@ -189,7 +189,7 @@ public function request(Http\Request $request): Http\Response * @throws MissingParameterException when substitution is used in URL but parameter is missing * @throws JsonException when encoding to JSON fails */ - public function createRequest(string $method, string $urlPath, array $parameters = [], array $headers = [], string|array|object $content = null): Http\Request + public function createRequest(string $method, string $urlPath, array $parameters = [], array $headers = [], string|array|object|null $content = null): Http\Request { if (stripos($urlPath, $this->url) === 0) { # Allows non-HTTPS URLs $baseUrl = $this->url; @@ -225,7 +225,7 @@ public function createRequest(string $method, string $urlPath, array $parameters * * @throws ApiException */ - public function decode(Http\Response $response, array $okCodes = null): mixed + public function decode(Http\Response $response, ?array $okCodes = null): mixed { $content = $response->getContent(); if (preg_match('~application/json~i', $response->getHeader('Content-Type', ''))) { @@ -460,7 +460,7 @@ private function prefix(array $flags, string $name, string $value): string } - private function escape(array $flags, string|int|false $value, int $maxLength = null): string + private function escape(array $flags, string|int|false $value, ?int $maxLength = null): string { $value = (string) $value; diff --git a/src/Github/Http/CachedClient.php b/src/Github/Http/CachedClient.php index 8077b08..967df83 100644 --- a/src/Github/Http/CachedClient.php +++ b/src/Github/Http/CachedClient.php @@ -28,7 +28,7 @@ class CachedClient implements IClient */ public function __construct( private Storages\ICache $cache, - IClient $client = null, + ?IClient $client = null, private bool $forbidRecheck = false, ) { $this->client = $client ?: Github\Helpers::createDefaultClient(); diff --git a/src/Github/Http/Message.php b/src/Github/Http/Message.php index 90fce0e..089c548 100644 --- a/src/Github/Http/Message.php +++ b/src/Github/Http/Message.php @@ -35,7 +35,7 @@ public function hasHeader(string $name): bool } - public function getHeader(string $name, string $default = null): ?string + public function getHeader(string $name, ?string $default = null): ?string { $name = strtolower($name); return array_key_exists($name, $this->headers) diff --git a/src/Github/Http/Request.php b/src/Github/Http/Request.php index 94bc4f9..4ac0207 100644 --- a/src/Github/Http/Request.php +++ b/src/Github/Http/Request.php @@ -26,7 +26,7 @@ public function __construct( private string $method, private string $url, array $headers = [], - string $content = null + ?string $content = null ) { parent::__construct($headers, $content); } diff --git a/src/Github/Http/Response.php b/src/Github/Http/Response.php index 29b529b..be602a4 100644 --- a/src/Github/Http/Response.php +++ b/src/Github/Http/Response.php @@ -63,7 +63,7 @@ public function getPrevious(): ?Response /** * @throws Github\LogicException */ - public function setPrevious(Response $previous = null): static + public function setPrevious(?Response $previous = null): static { if ($this->previous) { throw new Github\LogicException('Previous response is already set.'); diff --git a/src/Github/OAuth/Login.php b/src/Github/OAuth/Login.php index 060ff4b..7a8b9da 100644 --- a/src/Github/OAuth/Login.php +++ b/src/Github/OAuth/Login.php @@ -29,8 +29,8 @@ class Login public function __construct( private Configuration $conf, - Storages\ISessionStorage $storage = null, - Http\IClient $client = null + ?Storages\ISessionStorage $storage = null, + ?Http\IClient $client = null ) { $this->storage = $storage ?: new Storages\SessionStorage; $this->client = $client ?: Github\Helpers::createDefaultClient(); @@ -47,7 +47,7 @@ public function getClient(): Http\IClient * @param string $backUrl URL to redirect back from GitHub when user approves the permissions request * @param ?callable $redirectCb makes HTTP redirect to GitHub */ - public function askPermissions(string $backUrl, callable $redirectCb = null): void + public function askPermissions(string $backUrl, ?callable $redirectCb = null): void { /** @todo Something more safe? */ $state = sha1(uniqid((string) microtime(true), true)); diff --git a/src/Github/exceptions.php b/src/Github/exceptions.php index a23ffd8..d54494e 100644 --- a/src/Github/exceptions.php +++ b/src/Github/exceptions.php @@ -49,7 +49,7 @@ abstract class ApiException extends RuntimeException private ?Http\Response $response; - public function __construct(string $message = '', int $code = 0, \Exception $previous = null, Http\Response $response = null) + public function __construct(string $message = '', int $code = 0, ?\Exception $previous = null, ?Http\Response $response = null) { parent::__construct($message, $code, $previous); $this->response = clone $response;