Skip to content

Commit

Permalink
Make Cookie compatible with ArrayAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan authored Aug 18, 2021
1 parent 6ba40da commit 5c8d1ae
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions system/Cookie/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use DateTimeInterface;
use InvalidArgumentException;
use LogicException;
use ReturnTypeWillChange;

/**
* A `Cookie` class represents an immutable HTTP cookie value object.
Expand Down Expand Up @@ -562,24 +563,23 @@ public function withRaw(bool $raw = true)
/**
* Whether an offset exists.
*
* @param string $offset
*
* @return bool
* @param mixed $offset
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return $offset === 'expire' ? true : property_exists($this, $offset);
}

/**
* Offset to retrieve.
*
* @param string $offset
* @param mixed $offset
*
* @throws InvalidArgumentException
*
* @return mixed
*/
#[ReturnTypeWillChange]
public function offsetGet($offset)
{
if (! $this->offsetExists($offset)) {
Expand All @@ -592,24 +592,24 @@ public function offsetGet($offset)
/**
* Offset to set.
*
* @param string $offset
* @param mixed $value
* @param mixed $offset
* @param mixed $value
*
* @throws LogicException
*/
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
throw new LogicException(sprintf('Cannot set values of properties of %s as it is immutable.', static::class));
}

/**
* Offset to unset.
*
* @param string $offset
* @param mixed $offset
*
* @throws LogicException
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
throw new LogicException(sprintf('Cannot unset values of properties of %s as it is immutable.', static::class));
}
Expand Down

0 comments on commit 5c8d1ae

Please sign in to comment.