diff --git a/src/DataObject.php b/src/DataObject.php index 1f3317ed..34a0f16d 100644 --- a/src/DataObject.php +++ b/src/DataObject.php @@ -198,7 +198,7 @@ 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)); } @@ -206,11 +206,11 @@ public function getIterator() /** * 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(); } @@ -304,7 +304,7 @@ protected function setProperty($property, $value) * * @since 1.0 */ - public function count() + public function count(): int { return \count($this->properties); } diff --git a/src/DataSet.php b/src/DataSet.php index 95d97e85..5b48b09c 100644 --- a/src/DataSet.php +++ b/src/DataSet.php @@ -256,7 +256,7 @@ public function toArray($associative = true, ...$keys) * * @since 1.0 */ - public function count() + public function count(): int { return \count($this->objects); } @@ -268,7 +268,7 @@ public function count() * * @since 1.0 */ - public function clear() + public function clear(): DataSet { $this->objects = []; $this->rewind(); @@ -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; } @@ -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; } @@ -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(); @@ -430,7 +430,7 @@ public function next() * * @since 1.0 */ - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->objects[$offset]); } @@ -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; } @@ -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( @@ -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. @@ -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)) { @@ -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])) {