Skip to content

Commit

Permalink
Implement PHP 8.1's ArrayAccess interface (#3454)
Browse files Browse the repository at this point in the history
* Implement PHP 8.1's ArrayAccess interface

PHP 8.1 enforces return types for `ArrayAccess` implementations.

* Add changes to changelog

* Use #[\ReturnTypeWillChange] for PHP8.1 ArrayAccess

Co-authored-by: Patrick Brouwers <patrickbrouwersfilm@gmail.com>
  • Loading branch information
grantholle and patrickbrouwers authored Dec 2, 2021
1 parent e2240e5 commit 369537c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
- Fix queueImport function to be able to assert chained jobs
- Skipped failure no longer persists in `ToCollection` and `ToArray`.
- Fix missing InteractsWithQueue trait in AppendToSheet jobs
- Add return types to `Row`'s `ArrayAccess` implementation

## [3.1.33] - 2021-08-12

Expand Down
4 changes: 4 additions & 0 deletions src/Row.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,25 @@ public function getIndex(): int
return $this->row->getRowIndex();
}

#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return isset(($this->toArray())[$offset]);
}

#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return ($this->toArray())[$offset];
}

#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
//
}

#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
//
Expand Down

0 comments on commit 369537c

Please sign in to comment.