Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions src/DataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,19 @@ public function dump($depth = 3, ?\SplObjectStorage $dumped = null)
* @see IteratorAggregate::getIterator()
* @since 1.0
*/
public function getIterator()
public function getIterator(): \ArrayIterator
{
return new \ArrayIterator($this->dump(0));
}

/**
* Gets the data properties in a form that can be serialised to JSON format.
*
* @return mixed
* @return \stdClass
*
* @since 1.0
*/
public function jsonSerialize()
public function jsonSerialize(): \stdClass
{
return $this->dump();
}
Expand Down Expand Up @@ -304,7 +304,7 @@ protected function setProperty($property, $value)
*
* @since 1.0
*/
public function count()
public function count(): int
{
return \count($this->properties);
}
Expand Down
26 changes: 13 additions & 13 deletions src/DataSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public function toArray($associative = true, ...$keys)
*
* @since 1.0
*/
public function count()
public function count(): int
{
return \count($this->objects);
}
Expand All @@ -268,7 +268,7 @@ public function count()
*
* @since 1.0
*/
public function clear()
public function clear(): DataSet
{
$this->objects = [];
$this->rewind();
Expand All @@ -279,11 +279,11 @@ public function clear()
/**
* Get the current data object in the set.
*
* @return DataObject|false The current object, or false if the array is empty or the pointer is beyond the end of the elements.
* @return DataObject|bool The current object, or false if the array is empty or the pointer is beyond the end of the elements.
*
* @since 1.0
*/
public function current()
public function current(): DataObject|bool
{
return is_scalar($this->current) ? $this->objects[$this->current] : false;
}
Expand Down Expand Up @@ -350,11 +350,11 @@ public function jsonSerialize()
/**
* Gets the key of the current object in the iterator.
*
* @return integer|false The object key on success; false on failure.
* @return int|bool|null The object key on success; false on failure.
*
* @since 1.0
*/
public function key()
public function key(): int|bool|null
{
return $this->current;
}
Expand Down Expand Up @@ -397,7 +397,7 @@ public function walk(callable $funcname)
*
* @since 1.0
*/
public function next()
public function next(): void
{
// Get the object offsets.
$keys = $this->keys();
Expand Down Expand Up @@ -430,7 +430,7 @@ public function next()
*
* @since 1.0
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return isset($this->objects[$offset]);
}
Expand All @@ -444,7 +444,7 @@ public function offsetExists($offset)
*
* @since 1.0
*/
public function offsetGet($offset)
public function offsetGet($offset): DataObject|null
{
return $this->objects[$offset] ?? null;
}
Expand All @@ -460,7 +460,7 @@ public function offsetGet($offset)
* @since 1.0
* @throws \InvalidArgumentException if an object is not an instance of DataObject.
*/
public function offsetSet($offset, $object)
public function offsetSet($offset, $object): void
{
if (!($object instanceof DataObject)) {
throw new \InvalidArgumentException(
Expand Down Expand Up @@ -489,7 +489,7 @@ public function offsetSet($offset, $object)
*
* @since 1.0
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
if (!isset($this[$offset])) {
// Do nothing if the offset does not exist.
Expand Down Expand Up @@ -522,7 +522,7 @@ public function offsetUnset($offset)
*
* @since 1.0
*/
public function rewind()
public function rewind(): void
{
// Set the current position to the first object.
if (empty($this->objects)) {
Expand All @@ -540,7 +540,7 @@ public function rewind()
*
* @since 1.0
*/
public function valid()
public function valid(): bool
{
// Check the current position.
if (!is_scalar($this->current) || !isset($this->objects[$this->current])) {
Expand Down