From 37ed4ab36bb6e43f71010245850b8940c21682f6 Mon Sep 17 00:00:00 2001 From: Attila Fulop <1162360+fulopattila122@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:34:27 +0200 Subject: [PATCH] Fixed PHP IteratorAggregate, ArrayAccess and Countable-related deprecation notices - Ping #164 --- .../Support/ArrayAdjustmentCollection.php | 13 +++++++------ .../Support/RelationAdjustmentCollection.php | 13 +++++++------ src/Checkout/CheckoutManager.php | 8 ++++---- src/Checkout/Drivers/BaseCheckoutStore.php | 4 ++-- src/Checkout/Drivers/RequestStore.php | 4 ++-- src/Checkout/Drivers/SessionStore.php | 4 ++-- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/Adjustments/Support/ArrayAdjustmentCollection.php b/src/Adjustments/Support/ArrayAdjustmentCollection.php index 934cf1bd..e8bcaa63 100644 --- a/src/Adjustments/Support/ArrayAdjustmentCollection.php +++ b/src/Adjustments/Support/ArrayAdjustmentCollection.php @@ -15,6 +15,7 @@ namespace Vanilo\Adjustments\Support; use ArrayIterator; +use Traversable; use Vanilo\Adjustments\Contracts\Adjustable; use Vanilo\Adjustments\Contracts\Adjuster; use Vanilo\Adjustments\Contracts\Adjustment; @@ -99,17 +100,17 @@ public function byType(AdjustmentType $type): AdjustmentCollectionContract return $result; } - public function offsetExists($offset) + public function offsetExists(mixed $offset): bool { return isset($this->items[$offset]); } - public function offsetGet($offset) + public function offsetGet(mixed $offset): mixed { return $this->items[$offset]; } - public function offsetSet($offset, $value) + public function offsetSet(mixed $offset, mixed $value): void { if (!is_object($value) || ! ($value instanceof Adjustment)) { throw new \InvalidArgumentException('Only objects implementing the Adjustment interface can be used'); @@ -118,12 +119,12 @@ public function offsetSet($offset, $value) $this->items[$offset] = $value; } - public function offsetUnset($offset) + public function offsetUnset(mixed $offset): void { unset($this->items[$offset]); } - public function count() + public function count(): int { return count($this->items); } @@ -138,7 +139,7 @@ public function last(): ?Adjustment return $this->items[$this->count() - 1] ?? null; } - public function getIterator() + public function getIterator(): Traversable { return new ArrayIterator($this->items); } diff --git a/src/Adjustments/Support/RelationAdjustmentCollection.php b/src/Adjustments/Support/RelationAdjustmentCollection.php index 3d7167ca..a2bdb766 100644 --- a/src/Adjustments/Support/RelationAdjustmentCollection.php +++ b/src/Adjustments/Support/RelationAdjustmentCollection.php @@ -17,6 +17,7 @@ use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\MorphMany; +use Traversable; use Vanilo\Adjustments\Contracts\Adjustable; use Vanilo\Adjustments\Contracts\Adjuster; use Vanilo\Adjustments\Contracts\Adjustment; @@ -97,17 +98,17 @@ public function byType(AdjustmentType $type): AdjustmentCollection return $result; } - public function offsetExists($offset) + public function offsetExists(mixed $offset): bool { return $this->eloquentCollection()->offsetExists($offset); } - public function offsetGet($offset) + public function offsetGet(mixed $offset): mixed { return $this->eloquentCollection()->offsetGet($offset); } - public function offsetSet($offset, $value) + public function offsetSet(mixed $offset, mixed $value): void { if (!is_object($value) || ! ($value instanceof Adjustment)) { throw new \InvalidArgumentException('Only objects implementing the Adjustment interface can be used'); @@ -116,12 +117,12 @@ public function offsetSet($offset, $value) $this->eloquentCollection()->offsetSet($offset, $value); } - public function offsetUnset($offset) + public function offsetUnset(mixed $offset): void { $this->eloquentCollection()->offsetUnset($offset); } - public function count() + public function count(): int { return $this->eloquentCollection()->count(); } @@ -136,7 +137,7 @@ public function last(): ?Adjustment return $this->eloquentCollection()->last(); } - public function getIterator() + public function getIterator(): Traversable { return $this->eloquentCollection()->getIterator(); } diff --git a/src/Checkout/CheckoutManager.php b/src/Checkout/CheckoutManager.php index 4e8d34e5..ec578436 100644 --- a/src/Checkout/CheckoutManager.php +++ b/src/Checkout/CheckoutManager.php @@ -194,22 +194,22 @@ public function dimension(): ?Dimension return $this->store->dimension(); } - public function offsetExists(mixed $offset) + public function offsetExists(mixed $offset): bool { return $this->store->offsetExists($offset); } - public function offsetGet(mixed $offset) + public function offsetGet(mixed $offset): mixed { return $this->store->offsetGet($offset); } - public function offsetSet(mixed $offset, mixed $value) + public function offsetSet(mixed $offset, mixed $value): void { $this->store->offsetSet($offset, $value); } - public function offsetUnset(mixed $offset) + public function offsetUnset(mixed $offset): void { $this->store->offsetUnset($offset); } diff --git a/src/Checkout/Drivers/BaseCheckoutStore.php b/src/Checkout/Drivers/BaseCheckoutStore.php index 0a1290ca..b721efa1 100644 --- a/src/Checkout/Drivers/BaseCheckoutStore.php +++ b/src/Checkout/Drivers/BaseCheckoutStore.php @@ -188,7 +188,7 @@ public function dimension(): ?Dimension return null; } - public function offsetSet(mixed $offset, mixed $value) + public function offsetSet(mixed $offset, mixed $value): void { if ($this->isRegularAttribute($offset)) { $this->setAttribute($offset, $value); @@ -197,7 +197,7 @@ public function offsetSet(mixed $offset, mixed $value) } } - public function offsetGet(mixed $offset) + public function offsetGet(mixed $offset): mixed { if ($this->isRegularAttribute($offset)) { return $this->getAttribute($offset); diff --git a/src/Checkout/Drivers/RequestStore.php b/src/Checkout/Drivers/RequestStore.php index b9c4c6b9..2ef06a01 100644 --- a/src/Checkout/Drivers/RequestStore.php +++ b/src/Checkout/Drivers/RequestStore.php @@ -154,12 +154,12 @@ public function clear(): void $this->request->replace([]); } - public function offsetExists(mixed $offset) + public function offsetExists(mixed $offset): bool { return $this->request->has($offset); } - public function offsetUnset(mixed $offset) + public function offsetUnset(mixed $offset): void { $this->request->offsetUnset($offset); } diff --git a/src/Checkout/Drivers/SessionStore.php b/src/Checkout/Drivers/SessionStore.php index 54a10260..7c4caaec 100644 --- a/src/Checkout/Drivers/SessionStore.php +++ b/src/Checkout/Drivers/SessionStore.php @@ -113,7 +113,7 @@ public function getCustomAttributes(): array return $this->readRawDataFromStore(static::CUSTOM_ATTRIBUTES_KEY) ?? []; } - public function offsetExists(mixed $offset) + public function offsetExists(mixed $offset): bool { if ($this->isAnAliasAttribute($offset)) { $offset = $this->getTargetOfAlias($offset); @@ -122,7 +122,7 @@ public function offsetExists(mixed $offset) return in_array($offset, array_merge($this->attributesPlain, $this->attributesViaGetterSetter)); } - public function offsetUnset(mixed $offset) + public function offsetUnset(mixed $offset): void { $this->session->forget($offset); }