diff --git a/src/Traits/Collection/ArrayAccessTrait.php b/src/Traits/Collection/ArrayAccessTrait.php index 5db8567..faa6076 100644 --- a/src/Traits/Collection/ArrayAccessTrait.php +++ b/src/Traits/Collection/ArrayAccessTrait.php @@ -19,7 +19,7 @@ trait ArrayAccessTrait /** * {@inheritdoc} */ - public function offsetExists($offset) + public function offsetExists($offset): bool { return $this->exists($offset); } @@ -39,7 +39,7 @@ trait ArrayAccessTrait /** * {@inheritdoc} */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { $this->elements[$offset] = $value; } @@ -47,7 +47,7 @@ trait ArrayAccessTrait /** * {@inheritdoc} */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { if ($this->exists($offset)) { unset($this->elements[$offset]); @@ -60,7 +60,7 @@ trait ArrayAccessTrait * @param int|string $index The index/key of element * @return bool */ - private function exists($index) + private function exists($index): bool { return isset($this->elements[$index]) || array_key_exists($index, $this->elements); } diff --git a/src/Traits/Collection/CountableTrait.php b/src/Traits/Collection/CountableTrait.php index 4579d40..761581f 100644 --- a/src/Traits/Collection/CountableTrait.php +++ b/src/Traits/Collection/CountableTrait.php @@ -19,7 +19,7 @@ trait CountableTrait /** * {@inheritdoc} */ - public function count() + public function count(): int { return count($this->elements); } diff --git a/src/Traits/Collection/IteratorAggregateTrait.php b/src/Traits/Collection/IteratorAggregateTrait.php index 9c814b1..7430212 100644 --- a/src/Traits/Collection/IteratorAggregateTrait.php +++ b/src/Traits/Collection/IteratorAggregateTrait.php @@ -21,7 +21,7 @@ trait IteratorAggregateTrait /** * {@inheritdoc} */ - public function getIterator() + public function getIterator(): ArrayIterator { return new ArrayIterator($this->elements); } diff --git a/src/Traits/Collection/MainTrait.php b/src/Traits/Collection/MainTrait.php index 9188179..fae3153 100644 --- a/src/Traits/Collection/MainTrait.php +++ b/src/Traits/Collection/MainTrait.php @@ -33,7 +33,7 @@ trait MainTrait * @param mixed $index (optional) Index / key of the element * @return $this */ - public function add($element, $index = null) + public function add($element, $index = null): self { if (null === $index || '' === $index) { $this->elements[] = $element; @@ -52,7 +52,7 @@ trait MainTrait * this collection. Otherwise - not. * @return $this */ - public function addMultiple($elements, $useIndexes = false) + public function addMultiple($elements, bool $useIndexes = false): self { if (!empty($elements)) { foreach ($elements as $index => $element) { @@ -75,7 +75,7 @@ trait MainTrait * @param mixed $element The element to prepend * @return $this */ - public function prepend($element) + public function prepend($element): self { array_unshift($this->elements, $element); @@ -88,7 +88,7 @@ trait MainTrait * @param mixed $element The element to remove * @return $this */ - public function remove($element) + public function remove($element): self { if ($this->count() > 0) { foreach ($this->elements as $index => $existing) { @@ -108,7 +108,7 @@ trait MainTrait * * @return bool */ - public function isEmpty() + public function isEmpty(): bool { return empty($this->elements); } @@ -119,7 +119,7 @@ trait MainTrait * @param mixed $element The element to verify * @return bool */ - public function isFirst($element) + public function isFirst($element): bool { return reset($this->elements) === $element; } @@ -130,7 +130,7 @@ trait MainTrait * @param mixed $element The element to verify * @return bool */ - public function isLast($element) + public function isLast($element): bool { return end($this->elements) === $element; } @@ -141,7 +141,7 @@ trait MainTrait * @param mixed $element The element to verify * @return bool */ - public function has($element) + public function has($element): bool { $index = Arrays::getIndexOf($this->elements, $element); @@ -210,7 +210,7 @@ trait MainTrait * * @return array */ - public function toArray() + public function toArray(): array { return $this->elements; }