Skip to content

Make Cookie compatible with ArrayAccess #5004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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