Skip to content

Commit

Permalink
fix(deps): Update PhpCSFixer with null type changes (#23)
Browse files Browse the repository at this point in the history
PhpCsFixer 3.49 introduced `nullable_type_declaration_for_default_null_value`
which enforces implicit null types are defined in the declaration.

For us this introduced a `?` fix.

This change explicitly forces null types as unions and orders them last
  • Loading branch information
mikeymike authored Feb 5, 2024
1 parent 18a0773 commit 6bc7295
Show file tree
Hide file tree
Showing 64 changed files with 155 additions and 150 deletions.
5 changes: 5 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
'spacing' => 'one',
],
'self_accessor' => true,
'nullable_type_declaration' => ['syntax' => 'union'],
'ordered_types' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'none',
],
])
->setRiskyAllowed(true)
->setFinder($finder);
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"symfony/serializer": "^5.4 || ^6.3 || ^7.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "3.48",
"friendsofphp/php-cs-fixer": "^3.49",
"guzzlehttp/psr7": "^2.6",
"monolog/monolog": "^3.5",
"php-http/curl-client": "^2.3",
Expand Down
14 changes: 7 additions & 7 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ class Client

public function __construct(
#[\SensitiveParameter] private readonly string $apiKey,
Options $options = null,
HttpAsyncClient $httpClient = null,
LoggerInterface $logger = null,
RequestFactoryInterface $requestFactory = null,
StreamFactoryInterface $streamFactory = null,
UriFactoryInterface $uriFactory = null,
Options|null $options = null,
HttpAsyncClient|null $httpClient = null,
LoggerInterface|null $logger = null,
RequestFactoryInterface|null $requestFactory = null,
StreamFactoryInterface|null $streamFactory = null,
UriFactoryInterface|null $uriFactory = null,
) {
$this->options = $options ?: new Options();
$this->logger = $logger ?: new NullLogger();
Expand Down Expand Up @@ -159,7 +159,7 @@ public function deleteRaw(string|UriInterface $uri): ResponseInterface
return $this->requestRaw('DELETE', $uri);
}

private function requestRaw(string $method, string|UriInterface $uri, array|\JsonSerializable $payload = null): ResponseInterface
private function requestRaw(string $method, string|UriInterface $uri, array|\JsonSerializable|null $payload = null): ResponseInterface
{
if (\is_string($uri)) {
$components = \parse_url($this->options->environment->baseUrl());
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/AddressCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class AddressCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): Address => Address::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/AdjustmentCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class AdjustmentCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): Adjustment => Adjustment::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/BusinessCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class BusinessCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): Business => Business::from($item), $itemsData),
Expand Down
4 changes: 2 additions & 2 deletions src/Entities/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ abstract class Collection implements \Iterator

public function __construct(
protected array $items,
protected ?Paginator $paginator = null,
protected Paginator|null $paginator = null,
) {
}

abstract public static function from(array $data, ?Paginator $paginator): self;
abstract public static function from(array $data, Paginator|null $paginator): self;

public function current(): Entity
{
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/CreditBalanceCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class CreditBalanceCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): CreditBalance => CreditBalance::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/CustomerCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class CustomerCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): Customer => Customer::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/DiscountCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class DiscountCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): Discount => Discount::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/EventCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class EventCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): Event => Event::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/EventTypeCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class EventTypeCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): EventType => EventType::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/NotificationCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class NotificationCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): Notification => Notification::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/NotificationLogCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class NotificationLogCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): NotificationLog => NotificationLog::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/NotificationSettingCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class NotificationSettingCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): NotificationSetting => NotificationSetting::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/PriceCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class PriceCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): Price => Price::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/ProductCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class ProductCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): Product => Product::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/ReportCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class ReportCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): Report => Report::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/SubscriptionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class SubscriptionCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): Subscription => Subscription::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/SubscriptionPreviewCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class SubscriptionPreviewCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): SubscriptionPreview => SubscriptionPreview::from($item), $itemsData),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class SubscriptionsTransactionCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): SubscriptionTransaction => SubscriptionTransaction::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/TransactionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class TransactionCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): Transaction => Transaction::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/TransactionPreviewCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class TransactionPreviewCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): TransactionPreview => TransactionPreview::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Collections/TransactionsDataCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class TransactionsDataCollection extends Collection
{
public static function from(array $itemsData, Paginator $paginator = null): self
public static function from(array $itemsData, Paginator|null $paginator = null): self
{
return new self(
array_map(fn (array $item): TransactionData => TransactionData::from($item), $itemsData),
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct(string $datetime = 'now')
parent::__construct(datetime: $datetime, timezone: new \DateTimeZone('UTC'));
}

public function format(string $format = null): string
public function format(string|null $format = null): string
{
return parent::format($format ?? self::PADDLE_RFC3339);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
public string|null $description,
public CatalogType|null $type,
public TaxCategory $taxCategory,
public null|string $imageUrl,
public string|null $imageUrl,
public CustomData|null $customData,
public Status $status,
public \DateTimeInterface|null $createdAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(
public string|null $description,
public CatalogType|null $type,
public TaxCategory $taxCategory,
public null|string $imageUrl,
public string|null $imageUrl,
public CustomData|null $customData,
) {
}
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Transaction/TransactionNonCatalogProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(
public string $name,
public string|null $description,
public TaxCategory $taxCategory,
public null|string $imageUrl,
public string|null $imageUrl,
public CustomData|null $customData,
) {
}
Expand Down
2 changes: 1 addition & 1 deletion src/Notifications/Verifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
final class Verifier
{
public function __construct(
private readonly ?int $maximumVariance = 5,
private readonly int|null $maximumVariance = 5,
) {
}

Expand Down
14 changes: 7 additions & 7 deletions src/Resources/Addresses/Operations/CreateAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class CreateAddress implements \JsonSerializable

public function __construct(
public readonly CountryCode $countryCode,
public readonly string|null|Undefined $description = new Undefined(),
public readonly string|null|Undefined $firstLine = new Undefined(),
public readonly string|null|Undefined $secondLine = new Undefined(),
public readonly string|null|Undefined $city = new Undefined(),
public readonly string|null|Undefined $postalCode = new Undefined(),
public readonly string|null|Undefined $region = new Undefined(),
public readonly CustomData|null|Undefined $customData = new Undefined(),
public readonly string|Undefined|null $description = new Undefined(),
public readonly string|Undefined|null $firstLine = new Undefined(),
public readonly string|Undefined|null $secondLine = new Undefined(),
public readonly string|Undefined|null $city = new Undefined(),
public readonly string|Undefined|null $postalCode = new Undefined(),
public readonly string|Undefined|null $region = new Undefined(),
public readonly CustomData|Undefined|null $customData = new Undefined(),
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Resources/Addresses/Operations/ListAddresses.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
class ListAddresses implements HasParameters
{
public function __construct(
private readonly ?Pager $pager = null,
private readonly Pager|null $pager = null,
private readonly array $ids = [],
private readonly array $statuses = [],
private readonly ?string $search = null,
private readonly string|null $search = null,
) {
if ($invalid = array_filter($this->ids, fn ($value): bool => ! is_string($value))) {
throw InvalidArgumentException::arrayContainsInvalidTypes('ids', 'string', implode(', ', $invalid));
Expand Down
14 changes: 7 additions & 7 deletions src/Resources/Addresses/Operations/UpdateAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class UpdateAddress implements \JsonSerializable

public function __construct(
public readonly CountryCode|Undefined $countryCode = new Undefined(),
public readonly string|null|Undefined $description = new Undefined(),
public readonly string|null|Undefined $firstLine = new Undefined(),
public readonly string|null|Undefined $secondLine = new Undefined(),
public readonly string|null|Undefined $city = new Undefined(),
public readonly string|null|Undefined $postalCode = new Undefined(),
public readonly string|null|Undefined $region = new Undefined(),
public readonly CustomData|null|Undefined $customData = new Undefined(),
public readonly string|Undefined|null $description = new Undefined(),
public readonly string|Undefined|null $firstLine = new Undefined(),
public readonly string|Undefined|null $secondLine = new Undefined(),
public readonly string|Undefined|null $city = new Undefined(),
public readonly string|Undefined|null $postalCode = new Undefined(),
public readonly string|Undefined|null $region = new Undefined(),
public readonly CustomData|Undefined|null $customData = new Undefined(),
public readonly Status|Undefined $status = new Undefined(),
) {
}
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/Adjustments/Operations/ListAdjustments.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class ListAdjustments implements HasParameters
* @throws InvalidArgumentException On invalid array arguments
*/
public function __construct(
private readonly ?Pager $pager = null,
private readonly Pager|null $pager = null,
private readonly array $ids = [],
private readonly array $statuses = [],
private readonly array $customerIds = [],
private readonly array $transactionIds = [],
private readonly array $subscriptionIds = [],
private readonly ?Action $action = null,
private readonly Action|null $action = null,
) {
if ($invalid = array_filter($this->ids, fn ($value): bool => ! is_string($value))) {
throw InvalidArgumentException::arrayContainsInvalidTypes('ids', 'string', implode(', ', $invalid));
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/Businesses/Operations/CreateBusiness.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class CreateBusiness implements \JsonSerializable
*/
public function __construct(
public readonly string $name,
public readonly string|null|Undefined $companyNumber = new Undefined(),
public readonly string|null|Undefined $taxIdentifier = new Undefined(),
public readonly string|Undefined|null $companyNumber = new Undefined(),
public readonly string|Undefined|null $taxIdentifier = new Undefined(),
public readonly array|Undefined $contacts = new Undefined(),
public readonly CustomData|null|Undefined $customData = new Undefined(),
public readonly CustomData|Undefined|null $customData = new Undefined(),
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Resources/Businesses/Operations/ListBusinesses.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class ListBusinesses implements HasParameters
* @throws InvalidArgumentException On invalid array contents
*/
public function __construct(
private readonly ?Pager $pager = null,
private readonly Pager|null $pager = null,
private readonly array $ids = [],
private readonly array $statuses = [],
private readonly ?string $search = null,
private readonly string|null $search = null,
) {
if ($invalid = array_filter($this->ids, fn ($value): bool => ! is_string($value))) {
throw InvalidArgumentException::arrayContainsInvalidTypes('ids', 'string', implode(', ', $invalid));
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/Businesses/Operations/UpdateBusiness.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class UpdateBusiness implements \JsonSerializable
*/
public function __construct(
public readonly string|Undefined $name = new Undefined(),
public readonly string|null|Undefined $companyNumber = new Undefined(),
public readonly string|null|Undefined $taxIdentifier = new Undefined(),
public readonly string|Undefined|null $companyNumber = new Undefined(),
public readonly string|Undefined|null $taxIdentifier = new Undefined(),
public readonly array|Undefined $contacts = new Undefined(),
public readonly CustomData|null|Undefined $customData = new Undefined(),
public readonly CustomData|Undefined|null $customData = new Undefined(),
public readonly Status|Undefined $status = new Undefined(),
) {
}
Expand Down
Loading

0 comments on commit 6bc7295

Please sign in to comment.