Skip to content

Commit

Permalink
Migration to PHP 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alxbndrs committed Feb 19, 2021
1 parent 69af76e commit c3166ce
Show file tree
Hide file tree
Showing 35 changed files with 345 additions and 639 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.3'
php-version: '8.0'
tools: composer:v2

- name: Validate composer.json and composer.lock
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -29,11 +29,11 @@
},
"minimum-stability": "stable",
"require": {
"php": "^7.1",
"php": ">=7.4",
"ext-mbstring": "*",
"ext-openssl": "*",
"phpseclib/phpseclib": "^2.0",
"lcobucci/jwt": "3.3.3",
"lcobucci/jwt": "4.0",
"guzzlehttp/guzzle": "^6.0|^7.0"
},
"require-dev": {
Expand Down
30 changes: 14 additions & 16 deletions src/Api/AppleApiClient.php
@@ -1,24 +1,22 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Api;

use Azimo\Apple\Api\Exception\PublicKeyFetchingFailedException;
use Azimo\Apple\Api\Factory\ResponseFactory;
use GuzzleHttp;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Utils;

class AppleApiClient
final class AppleApiClient implements AppleApiClientInterface
{
/**
* @var GuzzleHttp\ClientInterface
*/
private $httpClient;

/**
* @var ResponseFactory
*/
private $responseFactory;
private ClientInterface $httpClient;
private ResponseFactory $responseFactory;

public function __construct(GuzzleHttp\ClientInterface $httpClient, ResponseFactory $responseFactory)
public function __construct(ClientInterface $httpClient, ResponseFactory $responseFactory)
{
$this->httpClient = $httpClient;
$this->responseFactory = $responseFactory;
Expand All @@ -27,14 +25,14 @@ public function __construct(GuzzleHttp\ClientInterface $httpClient, ResponseFact
public function getAuthKeys(): Response\JsonWebKeySetCollection
{
try {
$response = $this->httpClient->send(new GuzzleHttp\Psr7\Request('GET', 'auth/keys'));
} catch (GuzzleHttp\Exception\GuzzleException $exception) {
$response = $this->httpClient->send(new Request('GET', 'auth/keys'));
} catch (GuzzleException $exception) {
throw new PublicKeyFetchingFailedException($exception->getMessage(), $exception->getCode(), $exception);
}

try {
return $this->responseFactory->createFromArray(
GuzzleHttp\json_decode($response->getBody()->getContents(), true)
Utils::jsonDecode($response->getBody()->getContents(), true)
);
} catch (\InvalidArgumentException $exception) {
throw new Exception\InvalidResponseException(
Expand Down
10 changes: 10 additions & 0 deletions src/Api/AppleApiClientInterface.php
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Azimo\Apple\Api;

interface AppleApiClientInterface
{
public function getAuthKeys(): Response\JsonWebKeySetCollection;
}
8 changes: 4 additions & 4 deletions src/Api/Enum/CryptographicAlgorithmEnum.php
@@ -1,13 +1,13 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Api\Enum;

class CryptographicAlgorithmEnum
final class CryptographicAlgorithmEnum
{
public const KID_86D88KF = '86D88Kf';

public const KID_EXAUNML = 'eXaunmL';

public const KID_YUYXOY = 'YuyXoY';

public static function supportedAlgorithms(): array
Expand Down
6 changes: 4 additions & 2 deletions src/Api/Exception/InvalidResponseException.php
@@ -1,9 +1,11 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Api\Exception;

use InvalidArgumentException;

class InvalidResponseException extends InvalidArgumentException implements AppleApiExceptionInterface
final class InvalidResponseException extends InvalidArgumentException implements AppleApiExceptionInterface
{
}
6 changes: 4 additions & 2 deletions src/Api/Exception/PublicKeyFetchingFailedException.php
@@ -1,9 +1,11 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Api\Exception;

use RuntimeException;

class PublicKeyFetchingFailedException extends RuntimeException implements AppleApiExceptionInterface
final class PublicKeyFetchingFailedException extends RuntimeException implements AppleApiExceptionInterface
{
}
6 changes: 4 additions & 2 deletions src/Api/Exception/ResponseValidationException.php
@@ -1,9 +1,11 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Api\Exception;

use InvalidArgumentException;

class ResponseValidationException extends InvalidArgumentException implements AppleApiExceptionInterface
final class ResponseValidationException extends InvalidArgumentException implements AppleApiExceptionInterface
{
}
@@ -1,9 +1,11 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Api\Exception;

use InvalidArgumentException;

class UnsupportedCryptographicAlgorithmException extends InvalidArgumentException implements AppleApiExceptionInterface
final class UnsupportedCryptographicAlgorithmException extends InvalidArgumentException implements AppleApiExceptionInterface
{
}
4 changes: 3 additions & 1 deletion src/Api/Factory/ResponseFactory.php
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Api\Factory;

Expand Down
28 changes: 9 additions & 19 deletions src/Api/Response/JsonWebKeySet.php
@@ -1,50 +1,40 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Api\Response;

class JsonWebKeySet
{
/**
* The family of cryptographic algorithms used with the key.
*
* @var string
*/
private $kty;
private string $kty;

/**
* The unique identifier for the key.
*
* @var string
*/
private $kid;
private string $kid;

/**
* How the key was meant to be used; `sig` represents the signature.
*
* @var string
*/
private $use;
private string $use;

/**
* The specific cryptographic algorithm used with the key.
*
* @var string
*/
private $alg;
private string $alg;

/**
* The modulus for the RSA public key.
*
* @var string
*/
private $modulus;
private string $modulus;

/**
* The exponent for the RSA public key.
*
* @var string
*/
private $exponent;
private string $exponent;

public function __construct(string $kty, string $kid, string $use, string $alg, string $modulus, string $exponent)
{
Expand Down
6 changes: 4 additions & 2 deletions src/Api/Response/JsonWebKeySetCollection.php
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Api\Response;

Expand All @@ -10,7 +12,7 @@ class JsonWebKeySetCollection
/**
* @var JsonWebKeySet[]
*/
private $authKeys;
private array $authKeys;

public function __construct(array $authKeys)
{
Expand Down
4 changes: 3 additions & 1 deletion src/Auth/Exception/AppleExceptionInterface.php
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Auth\Exception;

Expand Down
6 changes: 4 additions & 2 deletions src/Auth/Exception/InvalidCryptographicAlgorithmException.php
@@ -1,9 +1,11 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Auth\Exception;

use InvalidArgumentException;

class InvalidCryptographicAlgorithmException extends InvalidArgumentException implements AppleExceptionInterface
final class InvalidCryptographicAlgorithmException extends InvalidArgumentException implements AppleExceptionInterface
{
}
6 changes: 4 additions & 2 deletions src/Auth/Exception/InvalidJwtException.php
@@ -1,9 +1,11 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Auth\Exception;

use InvalidArgumentException;

class InvalidJwtException extends InvalidArgumentException implements AppleExceptionInterface
final class InvalidJwtException extends InvalidArgumentException implements AppleExceptionInterface
{
}
6 changes: 4 additions & 2 deletions src/Auth/Exception/KeysFetchingFailedException.php
@@ -1,9 +1,11 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Auth\Exception;

use RuntimeException;

class KeysFetchingFailedException extends RuntimeException implements AppleExceptionInterface
final class KeysFetchingFailedException extends RuntimeException implements AppleExceptionInterface
{
}
6 changes: 4 additions & 2 deletions src/Auth/Exception/MissingClaimException.php
@@ -1,9 +1,11 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Auth\Exception;

use OutOfBoundsException;

class MissingClaimException extends OutOfBoundsException implements AppleExceptionInterface
final class MissingClaimException extends OutOfBoundsException implements AppleExceptionInterface
{
}
9 changes: 0 additions & 9 deletions src/Auth/Exception/NotSignedTokenException.php

This file was deleted.

6 changes: 4 additions & 2 deletions src/Auth/Exception/ValidationFailedException.php
@@ -1,9 +1,11 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Auth\Exception;

use InvalidArgumentException;

class ValidationFailedException extends InvalidArgumentException implements AppleExceptionInterface
final class ValidationFailedException extends InvalidArgumentException implements AppleExceptionInterface
{
}
6 changes: 4 additions & 2 deletions src/Auth/Exception/VerificationFailedException.php
@@ -1,9 +1,11 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Azimo\Apple\Auth\Exception;

use InvalidArgumentException;

class VerificationFailedException extends InvalidArgumentException implements AppleExceptionInterface
final class VerificationFailedException extends InvalidArgumentException implements AppleExceptionInterface
{
}

0 comments on commit c3166ce

Please sign in to comment.