Skip to content

Commit

Permalink
Chore/upgrade symfony (#2)
Browse files Browse the repository at this point in the history
* chore: update to symfony 6 & php8

* style: stan

* chore: upgrade to sf6.4

* chore: upgrade to sf6.4
  • Loading branch information
johnkhansrc authored Dec 1, 2023
1 parent d6fbcbb commit 2e90ad2
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 32 deletions.
17 changes: 9 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
}
],
"require": {
"php": "^7.4",
"symfony/http-client": "^5.4",
"symfony/config": "^5.4",
"symfony/dependency-injection": "^5.4",
"symfony/http-kernel": "^5.4",
"php": ">=8.3",
"symfony/http-client": "6.4.*",
"symfony/config": "6.4.*",
"symfony/dependency-injection": "v6.4.*",
"symfony/http-kernel": "6.4.*",
"ext-json": "*"
},
"autoload": {
Expand All @@ -28,8 +28,9 @@
}
},
"require-dev": {
"symfony/phpunit-bridge": "^6.0",
"symfony/framework-bundle": "5.4",
"symfony/browser-kit": "^5.4"
"symfony/phpunit-bridge": "^6.4",
"symfony/framework-bundle": "6.4.*",
"symfony/browser-kit": "6.4.*",
"phpstan/phpstan": "^1.10"
}
}
6 changes: 3 additions & 3 deletions src/Controller/IaphubWebhookEntrypointController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct(
public function index(Request $request): JsonResponse
{
if (!$this->requestValidator->isValidHeader($request)) {
return $this->json([], Response::HTTP_UNAUTHORIZED);
return $this->json(Response::HTTP_UNAUTHORIZED);
}

$payload = json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR);
Expand Down Expand Up @@ -117,8 +117,8 @@ public function index(Request $request): JsonResponse
return $this->json();
}

public function json(): JsonResponse
public function json(int $status = 200): JsonResponse
{
return new JsonResponse(null, 200);
return new JsonResponse(null, $status);
}
}
1 change: 1 addition & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('johnkhansrc_iaphub');
$rootNode = $treeBuilder->getRootNode();
/* @phpstan-ignore-next-line */
$rootNode
->children()
->scalarNode('apikey')
Expand Down
9 changes: 8 additions & 1 deletion src/Exception/IaphubBundleBadQueryStringException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@

class IaphubBundleBadQueryStringException extends Exception
{
public function __construct($uri, $expected, $rejected)
/**
* @param array<int, int|string> $expected
*/
public function __construct(?string $uri, array $expected, ?string $rejected)
{
if (!$uri || !$rejected) {
$uri = 'unknown uri';
$rejected = 'unknown rejected parameter';
}
$acceptedParameters = implode(', ', $expected);
$message = "Cant call $uri with query parameter '$rejected', accepted parameters: $acceptedParameters";

Expand Down
5 changes: 4 additions & 1 deletion src/Exception/IaphubBundleBadQueryStringValueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

class IaphubBundleBadQueryStringValueException extends Exception
{
public function __construct($uri, $expected, $rejected)
/**
* @param array<int, int|string> $expected
*/
public function __construct(string $uri, array $expected, string $rejected)
{
$acceptedParameters = implode(', ', $expected);
$message = "Cant call $uri with query parameter value '$rejected', accepted values: $acceptedParameters";
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/IaphubUnsuportedWebhookException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class IaphubUnsuportedWebhookException extends Exception
{
public function __construct($webhookType)
public function __construct(string $webhookType)
{
$message = "Unexpected webhook type: $webhookType";

Expand Down
1 change: 1 addition & 0 deletions src/Factory/Api/GetPurchasesFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class GetPurchasesFactory
{
/**
* @param mixed[] $data
* @throws \Exception
*/
public static function build(array $data): GetPurchases
Expand Down
1 change: 1 addition & 0 deletions src/Factory/Api/GetUserApiResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class GetUserApiResponseFactory
{
/**
* @param mixed[] $payload
* @throws Exception
*/
public static function build(array $payload): GetUserApiResponse
Expand Down
1 change: 1 addition & 0 deletions src/Factory/Api/PostUserReceiptResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class PostUserReceiptResponseFactory
{
/**
* @param mixed[] $data
* @throws \Exception
*/
public static function build(array $data): PostUserReceiptResponse
Expand Down
3 changes: 3 additions & 0 deletions src/Factory/Api/PurchaseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
class PurchaseFactory
{
/**
* @param mixed[] $purchasesData
* @return Purchase[]
* @throws Exception
*/
public static function buildPurchases(array $purchasesData): array
Expand All @@ -22,6 +24,7 @@ public static function buildPurchases(array $purchasesData): array
}

/**
* @param mixed[] $purchaseData
* @throws Exception
*/
public static function buildPurchase(array $purchaseData): Purchase
Expand Down
1 change: 1 addition & 0 deletions src/Factory/Api/ReceiptFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class ReceiptFactory
{
/**
* @param mixed[] $data
* @throws Exception
*/
public static function build(array $data): Receipt
Expand Down
1 change: 1 addition & 0 deletions src/Factory/Api/TransactionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class TransactionFactory
{
/**
* @param mixed[] $data
* @throws Exception
*/
public static function build(array $data): Transaction
Expand Down
12 changes: 6 additions & 6 deletions src/Model/Api/ActiveProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ public function setSku(string $sku): ActiveProducts
}

/**
* @return string
* @return string|null
*/
public function getPlatform(): string
public function getPlatform(): ?string
{
return $this->platform;
}
Expand All @@ -191,9 +191,9 @@ public function setPlatform(string $platform): ActiveProducts
}

/**
* @return string
* @return string|null
*/
public function getPurchase(): string
public function getPurchase(): ?string
{
return $this->purchase;
}
Expand Down Expand Up @@ -227,9 +227,9 @@ public function setPurchaseDate(DateTime $purchaseDate): ActiveProducts
}

/**
* @return bool
* @return bool|null
*/
public function isFamilyShare(): bool
public function isFamilyShare(): ?bool
{
return $this->isFamilyShare;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Model/Api/GetUserApiResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class GetUserApiResponse
{
/**
* User tags.
* @var string[]|null
*/
private ?array $tags;
/**
Expand All @@ -20,7 +21,7 @@ class GetUserApiResponse
private array $activeProducts;

/**
* @param array|null $tags
* @param string[]|null $tags
* @param ProductsForSale[] $productsForSale
* @param ActiveProducts[] $activeProducts
*/
Expand All @@ -32,15 +33,15 @@ public function __construct(?array $tags, array $productsForSale, array $activeP
}

/**
* @return array|null
* @return string[]|null
*/
public function getTags(): ?array
{
return $this->tags;
}

/**
* @param array|null $tags
* @param string[]|null $tags
* @return GetUserApiResponse
*/
public function setTags(?array $tags): GetUserApiResponse
Expand Down
14 changes: 10 additions & 4 deletions src/Model/Api/Purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Purchase
private string $country;
/**
* Tags of the user on purchase.
* @var string[]
*/
private array $tags;
/**
Expand All @@ -50,6 +51,7 @@ class Purchase
/**
* Only if the mode allowing an user to have multiple user ids is enabled
* User ids of the user owning the purchase (A purchase can be owned by multiple user ids if restored).
* @var string[]|null
*/
private ?array $userIds;
/**
Expand Down Expand Up @@ -280,6 +282,10 @@ class Purchase
*/
private ?string $originalPurchase;

/**
* @param string[] $tags
* @param string[]|null $userIds
*/
public function __construct(string $id,
DateTime $purchaseDate,
int $quantity,
Expand Down Expand Up @@ -472,15 +478,15 @@ public function setCountry(string $country): Purchase
}

/**
* @return array
* @return string[]
*/
public function getTags(): array
{
return $this->tags;
}

/**
* @param array $tags
* @param string[] $tags
* @return Purchase
*/
public function setTags(array $tags): Purchase
Expand Down Expand Up @@ -562,15 +568,15 @@ public function setUserId(string $userId): Purchase
}

/**
* @return array|null
* @return string[]|null
*/
public function getUserIds(): ?array
{
return $this->userIds;
}

/**
* @param array|null $userIds
* @param string[]|null $userIds
* @return Purchase
*/
public function setUserIds(?array $userIds): Purchase
Expand Down
Loading

0 comments on commit 2e90ad2

Please sign in to comment.