From 8233497e3f4ed62a75fdf243713e3d01f81e3073 Mon Sep 17 00:00:00 2001 From: Felipe Nunes Azambuja Date: Wed, 23 Mar 2022 16:58:45 -0300 Subject: [PATCH] Update for php 8.1 Add support for new php 8.1 changes --- src/Stringy.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Stringy.php b/src/Stringy.php index f2a77d6c..9e7d9a29 100644 --- a/src/Stringy.php +++ b/src/Stringy.php @@ -267,7 +267,7 @@ public function containsAny($needles, $caseSensitive = true) * * @return int The number of characters in the string, given the encoding */ - public function count() + public function count():int { return $this->length(); } @@ -450,7 +450,7 @@ public function getEncoding() * * @return \ArrayIterator An iterator for the characters in the string */ - public function getIterator() + public function getIterator(): ArrayIterator { return new ArrayIterator($this->chars()); } @@ -847,7 +847,7 @@ public function lowerCaseFirst() * @param mixed $offset The index to check * @return boolean Whether or not the index exists */ - public function offsetExists($offset) + public function offsetExists($offset): bool { $length = $this->length(); $offset = (int) $offset; @@ -870,7 +870,7 @@ public function offsetExists($offset) * @throws \OutOfBoundsException If the positive or negative offset does * not exist */ - public function offsetGet($offset) + public function offsetGet($offset):mixed { $offset = (int) $offset; $length = $this->length(); @@ -890,7 +890,7 @@ public function offsetGet($offset) * @param mixed $value Value to set * @throws \Exception When called */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value):void { // Stringy is immutable, cannot directly set char throw new Exception('Stringy object is immutable, cannot modify char'); @@ -903,7 +903,7 @@ public function offsetSet($offset, $value) * @param mixed $offset The index of the character * @throws \Exception When called */ - public function offsetUnset($offset) + public function offsetUnset($offset):void { // Don't allow directly modifying the string throw new Exception('Stringy object is immutable, cannot unset char');