diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 408107d..29ef794 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -33,7 +33,7 @@ jobs: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" - name: "Run PHP CS Fixer" run: "vendor/bin/php-cs-fixer fix --verbose --dry-run" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index d612d44..d267576 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -42,7 +42,7 @@ jobs: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" - name: "Run PHPUnit" run: "php vendor/bin/simple-phpunit -v" @@ -74,7 +74,7 @@ jobs: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" - name: "Setup logs" run: "mkdir -p build/logs" diff --git a/lib/Imgur/Api/AbstractApi.php b/lib/Imgur/Api/AbstractApi.php index fbf7120..bdc1a55 100644 --- a/lib/Imgur/Api/AbstractApi.php +++ b/lib/Imgur/Api/AbstractApi.php @@ -23,7 +23,7 @@ abstract class AbstractApi */ protected $pager; - public function __construct(Client $client, PagerInterface $pager = null) + public function __construct(Client $client, ?PagerInterface $pager = null) { $this->client = $client; $this->pager = $pager; diff --git a/lib/Imgur/Auth/AuthInterface.php b/lib/Imgur/Auth/AuthInterface.php index 79fda82..a109ff5 100644 --- a/lib/Imgur/Auth/AuthInterface.php +++ b/lib/Imgur/Auth/AuthInterface.php @@ -15,11 +15,11 @@ interface AuthInterface * @param string $responseType (code, token, pin) Determines if Imgur should return an authorization_code, a PIN code, or an opaque access_token * @param string $state Any value which you want Imgur to pass back */ - public function getAuthenticationUrl(string $responseType = 'code', string $state = null): string; + public function getAuthenticationUrl(string $responseType = 'code', ?string $state = null): string; public function getAccessToken(): ?array; - public function requestAccessToken(string $code, string $requestType = null): array; + public function requestAccessToken(string $code, ?string $requestType = null): array; public function setAccessToken(array $accessToken): void; diff --git a/lib/Imgur/Auth/OAuth2.php b/lib/Imgur/Auth/OAuth2.php index d6142db..b5e07ed 100644 --- a/lib/Imgur/Auth/OAuth2.php +++ b/lib/Imgur/Auth/OAuth2.php @@ -72,7 +72,7 @@ public function __construct(HttpClientInterface $httpClient, string $clientId, s /** * Generates the authentication URL to which a user should be pointed at in order to start the OAuth2 process. */ - public function getAuthenticationURL(string $responseType = 'code', string $state = null): string + public function getAuthenticationURL(string $responseType = 'code', ?string $state = null): string { $httpQueryParameters = [ 'client_id' => $this->clientId, @@ -88,7 +88,7 @@ public function getAuthenticationURL(string $responseType = 'code', string $stat /** * Exchanges a code/pin for an access token. */ - public function requestAccessToken(string $code, string $requestType = null): array + public function requestAccessToken(string $code, ?string $requestType = null): array { switch ($requestType) { case 'pin': @@ -166,7 +166,7 @@ public function refreshToken(): array * * @throws AuthException */ - public function setAccessToken(array $token = null): void + public function setAccessToken(?array $token = null): void { if (!\is_array($token)) { throw new AuthException('Token is not a valid json string.'); diff --git a/lib/Imgur/Client.php b/lib/Imgur/Client.php index 2384180..a454dd8 100644 --- a/lib/Imgur/Client.php +++ b/lib/Imgur/Client.php @@ -42,7 +42,7 @@ class Client * * @param HttpClientInterface|null $httpClient Imgur http client */ - public function __construct(AuthInterface $authenticationClient = null, HttpClientInterface $httpClient = null) + public function __construct(?AuthInterface $authenticationClient = null, ?HttpClientInterface $httpClient = null) { $this->httpClient = $httpClient; $this->authenticationClient = $authenticationClient; @@ -51,7 +51,7 @@ public function __construct(AuthInterface $authenticationClient = null, HttpClie /** * @throws InvalidArgumentException */ - public function api(string $name, PagerInterface $pager = null): AbstractApi + public function api(string $name, ?PagerInterface $pager = null): AbstractApi { if (!$this->getAccessToken()) { $this->sign(); @@ -97,7 +97,7 @@ public function getOption(string $name): ?string /** * @throws InvalidArgumentException */ - public function setOption(string $name, string $value = null): void + public function setOption(string $name, ?string $value = null): void { if (!\array_key_exists($name, $this->options)) { throw new InvalidArgumentException(sprintf('Undefined option called: "%s"', $name)); @@ -125,7 +125,7 @@ public function getAuthenticationClient(): AuthInterface /** * Proxy method for the authentication objects URL building method. */ - public function getAuthenticationUrl(string $responseType = 'code', string $state = null): string + public function getAuthenticationUrl(string $responseType = 'code', ?string $state = null): string { return $this->getAuthenticationClient()->getAuthenticationUrl($responseType, $state); } diff --git a/lib/Imgur/HttpClient/HttpClient.php b/lib/Imgur/HttpClient/HttpClient.php index f9f0daa..d21f5f8 100644 --- a/lib/Imgur/HttpClient/HttpClient.php +++ b/lib/Imgur/HttpClient/HttpClient.php @@ -37,7 +37,7 @@ class HttpClient implements HttpClientInterface /** @var HandlerStack */ protected $stack; - public function __construct(array $options = [], ClientInterface $client = null, HandlerStack $stack = null) + public function __construct(array $options = [], ?ClientInterface $client = null, ?HandlerStack $stack = null) { $this->options = array_merge($options, $this->options); diff --git a/tests/HttpClient/HttpClientTest.php b/tests/HttpClient/HttpClientTest.php index 7782250..5ae2cc9 100644 --- a/tests/HttpClient/HttpClientTest.php +++ b/tests/HttpClient/HttpClientTest.php @@ -292,7 +292,7 @@ class TestHttpClient extends HttpClient /** * @return array|string|null */ - public function getOption(string $name, string $default = null) + public function getOption(string $name, ?string $default = null) { return $this->options[$name] ?? $default; }