From a7224a8b67e53289c7e8533d4a82a3f02e698252 Mon Sep 17 00:00:00 2001 From: Attila Fulop <1162360+fulopattila122@users.noreply.github.com> Date: Wed, 6 Dec 2023 13:50:49 +0200 Subject: [PATCH] Added the `?CheckoutSubject` return type to `Checkout::getCart()` --- Changelog.md | 3 ++- src/Checkout/Changelog.md | 1 + src/Checkout/CheckoutManager.php | 2 +- src/Checkout/Contracts/Checkout.php | 7 +------ src/Checkout/Drivers/BaseCheckoutStore.php | 2 +- src/Checkout/Tests/Example/MemoryStore.php | 2 +- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Changelog.md b/Changelog.md index 71e983302..01b1522ad 100644 --- a/Changelog.md +++ b/Changelog.md @@ -29,7 +29,8 @@ - Added the `units_sold` and the `last_sale_at` attributes to the master product model (SUM/MAX from variants) - Added the `Stockable` interface (Contracts) - Added the `Stockable` interface to the `Product` and `MasterProductVariant` models -- Added the `backorder` field to products and product variants +- Added the `backorder` field to products and product variants +- BC: Added the `?CheckoutSubject` return type to the `getCart()` method of the `Checkout` interface - Fixed possible null return type on Billpayer::getName() when is_organization is true but the company name is null ## 3.x Series diff --git a/src/Checkout/Changelog.md b/src/Checkout/Changelog.md index 184c6f4f7..f7ea5d3c5 100644 --- a/src/Checkout/Changelog.md +++ b/src/Checkout/Changelog.md @@ -9,6 +9,7 @@ - Dropped Laravel 9 Support - Dropped Enum v3 Support - Changed minimal Enum requirement to v4.1 +- BC: Added the `?CheckoutSubject` return type to the `getCart()` method of the `Checkout` interface ## 3.x Series diff --git a/src/Checkout/CheckoutManager.php b/src/Checkout/CheckoutManager.php index ec5784362..4179f67b0 100644 --- a/src/Checkout/CheckoutManager.php +++ b/src/Checkout/CheckoutManager.php @@ -52,7 +52,7 @@ public function __get(string $name) /** * @inheritDoc */ - public function getCart() + public function getCart(): ?CheckoutSubject { return $this->store->getCart(); } diff --git a/src/Checkout/Contracts/Checkout.php b/src/Checkout/Contracts/Checkout.php index ca1e38e8f..e70c1522a 100644 --- a/src/Checkout/Contracts/Checkout.php +++ b/src/Checkout/Contracts/Checkout.php @@ -20,12 +20,7 @@ interface Checkout { - /** - * Returns the cart - * @todo add typehint in v4 - * @return CheckoutSubject|null - */ - public function getCart(); + public function getCart(): ?CheckoutSubject; /** * Set the cart for the checkout diff --git a/src/Checkout/Drivers/BaseCheckoutStore.php b/src/Checkout/Drivers/BaseCheckoutStore.php index b721efa17..c62b8688b 100644 --- a/src/Checkout/Drivers/BaseCheckoutStore.php +++ b/src/Checkout/Drivers/BaseCheckoutStore.php @@ -56,7 +56,7 @@ public function __construct( ) { } - public function getCart() + public function getCart(): ?CheckoutSubject { return $this->cart; } diff --git a/src/Checkout/Tests/Example/MemoryStore.php b/src/Checkout/Tests/Example/MemoryStore.php index 4eaa14a26..a5faaaf69 100644 --- a/src/Checkout/Tests/Example/MemoryStore.php +++ b/src/Checkout/Tests/Example/MemoryStore.php @@ -46,7 +46,7 @@ public function __get(string $name) } } - public function getCart() + public function getCart(): ?CheckoutSubject { return $this->cart; }