Skip to content

Commit

Permalink
Return types for php 8.1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
hpatel-mm committed Sep 29, 2023
1 parent cf5e251 commit 150993d
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/FieldType/DBMultiResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Exception;
use SilverStripe\ORM\Limitable;
use SilverStripe\ORM\Map;
use Traversable;

abstract class DBMultiResource extends DBBaseResource implements ArrayAccess, Countable, IteratorAggregate, Limitable
{
Expand Down Expand Up @@ -60,7 +61,7 @@ public function setValue($value, $record = null, $markChanged = true)
/**
* @return ArrayIterator
*/
public function getIterator()
public function getIterator(): Traversable
{
return new ArrayIterator($this->items);
}
Expand All @@ -69,7 +70,7 @@ public function getIterator()
* @param int $offset
* @return boolean
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return array_key_exists($offset, $this->items);
}
Expand All @@ -78,7 +79,7 @@ public function offsetExists($offset)
* @param int $offset
* @return DBSingleResource|null
*/
public function offsetGet($offset)
public function offsetGet($offset): mixed
{
if ($this->offsetExists($offset)) {
return $this->items[$offset];
Expand All @@ -90,34 +91,28 @@ public function offsetGet($offset)
/**
* @param int $offset
* @param DBSingleResource $value
* @return $this
*/
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
if ($offset == null) {
$this->items[] = $value;
} else {
$this->items[$offset] = $value;
}

return $this;
}

/**
* @param int $offset
* @return $this
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
unset($this->items[$offset]);

return $this;
}

/**
* @return int
*/
public function count()
public function count(): int
{
return count($this->items);
}
Expand Down

0 comments on commit 150993d

Please sign in to comment.