Skip to content
Open
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
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