From 0cad7385b67cba1e9ab47198150d3eaca635776a Mon Sep 17 00:00:00 2001 From: WillemDeGroef Date: Wed, 5 Nov 2025 09:35:07 +0100 Subject: [PATCH 1/3] fix: change Item date type from null to DateTimeInterface --- src/Documents/DocumentCreate/Item.php | 12 ++++-------- src/Documents/DocumentCreateParams/Item.php | 12 ++++-------- src/Documents/DocumentNewFromPdfResponse/Item.php | 12 ++++-------- src/Documents/DocumentResponse/Item.php | 12 ++++-------- src/Validate/ValidateValidateJsonParams/Item.php | 12 ++++-------- 5 files changed, 20 insertions(+), 40 deletions(-) diff --git a/src/Documents/DocumentCreate/Item.php b/src/Documents/DocumentCreate/Item.php index b9928793..784bd44d 100644 --- a/src/Documents/DocumentCreate/Item.php +++ b/src/Documents/DocumentCreate/Item.php @@ -16,7 +16,7 @@ * allowances?: list|null, * amount?: float|string|null, * charges?: list|null, - * date?: null|null, + * date?: \DateTimeInterface|null, * description?: string|null, * productCode?: string|null, * quantity?: float|string|null, @@ -53,9 +53,8 @@ final class Item implements BaseModel #[Api(list: Charge::class, nullable: true, optional: true)] public ?array $charges; - /** @var null|null $date */ #[Api(nullable: true, optional: true)] - public null $date; + public ?\DateTimeInterface $date; /** * The description of the line item. @@ -119,7 +118,7 @@ public static function with( ?array $allowances = null, float|string|null $amount = null, ?array $charges = null, - null $date = null, + ?\DateTimeInterface $date = null, ?string $description = null, ?string $productCode = null, float|string|null $quantity = null, @@ -182,10 +181,7 @@ public function withCharges(?array $charges): self return $obj; } - /** - * @param null|null $date - */ - public function withDate(null $date): self + public function withDate(?\DateTimeInterface $date): self { $obj = clone $this; $obj->date = $date; diff --git a/src/Documents/DocumentCreateParams/Item.php b/src/Documents/DocumentCreateParams/Item.php index 35efec77..b7fa5f4e 100644 --- a/src/Documents/DocumentCreateParams/Item.php +++ b/src/Documents/DocumentCreateParams/Item.php @@ -16,7 +16,7 @@ * allowances?: list|null, * amount?: float|string|null, * charges?: list|null, - * date?: null|null, + * date?: \DateTimeInterface|null, * description?: string|null, * productCode?: string|null, * quantity?: float|string|null, @@ -53,9 +53,8 @@ final class Item implements BaseModel #[Api(list: Charge::class, nullable: true, optional: true)] public ?array $charges; - /** @var null|null $date */ #[Api(nullable: true, optional: true)] - public null $date; + public ?\DateTimeInterface $date; /** * The description of the line item. @@ -119,7 +118,7 @@ public static function with( ?array $allowances = null, float|string|null $amount = null, ?array $charges = null, - null $date = null, + ?\DateTimeInterface $date = null, ?string $description = null, ?string $productCode = null, float|string|null $quantity = null, @@ -182,10 +181,7 @@ public function withCharges(?array $charges): self return $obj; } - /** - * @param null|null $date - */ - public function withDate(null $date): self + public function withDate(?\DateTimeInterface $date): self { $obj = clone $this; $obj->date = $date; diff --git a/src/Documents/DocumentNewFromPdfResponse/Item.php b/src/Documents/DocumentNewFromPdfResponse/Item.php index 92344683..c4cab023 100644 --- a/src/Documents/DocumentNewFromPdfResponse/Item.php +++ b/src/Documents/DocumentNewFromPdfResponse/Item.php @@ -16,7 +16,7 @@ * allowances?: list|null, * amount?: string|null, * charges?: list|null, - * date?: null|null, + * date?: \DateTimeInterface|null, * description?: string|null, * productCode?: string|null, * quantity?: string|null, @@ -53,9 +53,8 @@ final class Item implements BaseModel #[Api(list: Charge::class, nullable: true, optional: true)] public ?array $charges; - /** @var null|null $date */ #[Api(nullable: true, optional: true)] - public null $date; + public ?\DateTimeInterface $date; /** * The description of the line item. @@ -119,7 +118,7 @@ public static function with( ?array $allowances = null, ?string $amount = null, ?array $charges = null, - null $date = null, + ?\DateTimeInterface $date = null, ?string $description = null, ?string $productCode = null, ?string $quantity = null, @@ -182,10 +181,7 @@ public function withCharges(?array $charges): self return $obj; } - /** - * @param null|null $date - */ - public function withDate(null $date): self + public function withDate(?\DateTimeInterface $date): self { $obj = clone $this; $obj->date = $date; diff --git a/src/Documents/DocumentResponse/Item.php b/src/Documents/DocumentResponse/Item.php index 32fb1ece..ad7d627b 100644 --- a/src/Documents/DocumentResponse/Item.php +++ b/src/Documents/DocumentResponse/Item.php @@ -16,7 +16,7 @@ * allowances?: list|null, * amount?: string|null, * charges?: list|null, - * date?: null|null, + * date?: \DateTimeInterface|null, * description?: string|null, * productCode?: string|null, * quantity?: string|null, @@ -53,9 +53,8 @@ final class Item implements BaseModel #[Api(list: Charge::class, nullable: true, optional: true)] public ?array $charges; - /** @var null|null $date */ #[Api(nullable: true, optional: true)] - public null $date; + public ?\DateTimeInterface $date; /** * The description of the line item. @@ -119,7 +118,7 @@ public static function with( ?array $allowances = null, ?string $amount = null, ?array $charges = null, - null $date = null, + ?\DateTimeInterface $date = null, ?string $description = null, ?string $productCode = null, ?string $quantity = null, @@ -182,10 +181,7 @@ public function withCharges(?array $charges): self return $obj; } - /** - * @param null|null $date - */ - public function withDate(null $date): self + public function withDate(?\DateTimeInterface $date): self { $obj = clone $this; $obj->date = $date; diff --git a/src/Validate/ValidateValidateJsonParams/Item.php b/src/Validate/ValidateValidateJsonParams/Item.php index e43054d9..d014e9c6 100644 --- a/src/Validate/ValidateValidateJsonParams/Item.php +++ b/src/Validate/ValidateValidateJsonParams/Item.php @@ -16,7 +16,7 @@ * allowances?: list|null, * amount?: float|string|null, * charges?: list|null, - * date?: null|null, + * date?: \DateTimeInterface|null, * description?: string|null, * productCode?: string|null, * quantity?: float|string|null, @@ -53,9 +53,8 @@ final class Item implements BaseModel #[Api(list: Charge::class, nullable: true, optional: true)] public ?array $charges; - /** @var null|null $date */ #[Api(nullable: true, optional: true)] - public null $date; + public ?\DateTimeInterface $date; /** * The description of the line item. @@ -119,7 +118,7 @@ public static function with( ?array $allowances = null, float|string|null $amount = null, ?array $charges = null, - null $date = null, + ?\DateTimeInterface $date = null, ?string $description = null, ?string $productCode = null, float|string|null $quantity = null, @@ -182,10 +181,7 @@ public function withCharges(?array $charges): self return $obj; } - /** - * @param null|null $date - */ - public function withDate(null $date): self + public function withDate(?\DateTimeInterface $date): self { $obj = clone $this; $obj->date = $date; From a292d5f37507c5a4323a7a292b401b38d0062853 Mon Sep 17 00:00:00 2001 From: WillemDeGroef Date: Wed, 5 Nov 2025 09:38:23 +0100 Subject: [PATCH 2/3] fix: resolve PHPStan ArrayAccess and return type errors --- src/DocumentsNumberPage.php | 4 ++-- src/DocumentsNumberPage/Item.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/DocumentsNumberPage.php b/src/DocumentsNumberPage.php index 381a918e..4f0d7002 100644 --- a/src/DocumentsNumberPage.php +++ b/src/DocumentsNumberPage.php @@ -106,9 +106,9 @@ public function getItems(): array * body: mixed, * }, * RequestOptions, - * }|null + * } */ - public function nextRequest(): ?array + public function nextRequest(): array { $currentPage = $this->page ?? 1; $nextRequest = $this->request; diff --git a/src/DocumentsNumberPage/Item.php b/src/DocumentsNumberPage/Item.php index 7ca75a74..bcabfe05 100644 --- a/src/DocumentsNumberPage/Item.php +++ b/src/DocumentsNumberPage/Item.php @@ -8,7 +8,7 @@ use EInvoiceAPI\Core\Contracts\BaseModel; /** - * @phpstan-type ItemShape = array{} + * @phpstan-type ItemShape = array */ final class Item implements BaseModel { From 31a4de875020656628fe71983b87c453e9a96369 Mon Sep 17 00:00:00 2001 From: WillemDeGroef Date: Wed, 5 Nov 2025 09:47:17 +0100 Subject: [PATCH 3/3] fix: resolve PHPStan pagination type errors --- src/Core/Concerns/SdkPage.php | 2 +- src/DocumentsNumberPage.php | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Core/Concerns/SdkPage.php b/src/Core/Concerns/SdkPage.php index 96e2aa54..0f4d40da 100644 --- a/src/Core/Concerns/SdkPage.php +++ b/src/Core/Concerns/SdkPage.php @@ -57,7 +57,7 @@ public function hasNextPage(): bool public function getNextPage(): static { $next = $this->nextRequest(); - if (!$next) { + if ($next === null) { throw new \RuntimeException( 'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.' ); diff --git a/src/DocumentsNumberPage.php b/src/DocumentsNumberPage.php index 4f0d7002..3bf10853 100644 --- a/src/DocumentsNumberPage.php +++ b/src/DocumentsNumberPage.php @@ -106,12 +106,26 @@ public function getItems(): array * body: mixed, * }, * RequestOptions, - * } + * }|null */ - public function nextRequest(): array + public function nextRequest(): ?array { $currentPage = $this->page ?? 1; + $pageSize = $this->pageSize ?? 0; + $total = $this->total ?? 0; + + // Check if there are more pages + if ($pageSize === 0 || $total === 0) { + return null; + } + + $totalPages = (int) ceil($total / $pageSize); + if ($currentPage >= $totalPages) { + return null; + } + $nextRequest = $this->request; + $nextRequest['query']['page'] = $currentPage + 1; return [$nextRequest, $this->options]; }