Skip to content

Commit

Permalink
Fixed PHP IteratorAggregate, ArrayAccess and Countable-related deprec…
Browse files Browse the repository at this point in the history
…ation notices

- Ping #164

(cherry picked from commit 37ed4ab)
  • Loading branch information
fulopattila122 committed Nov 17, 2023
1 parent 9617cf8 commit 41f5f52
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
13 changes: 7 additions & 6 deletions src/Adjustments/Support/ArrayAdjustmentCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down
13 changes: 7 additions & 6 deletions src/Adjustments/Support/RelationAdjustmentCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand All @@ -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();
}
Expand All @@ -136,7 +137,7 @@ public function last(): ?Adjustment
return $this->eloquentCollection()->last();
}

public function getIterator()
public function getIterator(): Traversable
{
return $this->eloquentCollection()->getIterator();
}
Expand Down
8 changes: 4 additions & 4 deletions src/Checkout/CheckoutManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Checkout/Drivers/BaseCheckoutStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Checkout/Drivers/RequestStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Checkout/Drivers/SessionStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down

0 comments on commit 41f5f52

Please sign in to comment.