Skip to content

Commit e1eb21e

Browse files
authored
PHP 8.1 (#25)
PHP Fatal error: During inheritance of Iterator: Uncaught ErrorException: Return type of DCarbone\PHPConsulAPI\Values::current() should either be compatible with Iterator::current(): mixed, or the \#[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /code/vendor/dcarbone/php-consul-api/src/Values.php:104
1 parent d344660 commit e1eb21e

5 files changed

+12
-8
lines changed

src/AbstractValuedQueryResponse.php

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function offsetExists($offset): bool
3939
* @param mixed $offset
4040
* @return \DCarbone\PHPConsulAPI\Error|\DCarbone\PHPConsulAPI\QueryMeta|mixed|null
4141
*/
42+
#[\ReturnTypeWillChange]
4243
public function offsetGet($offset)
4344
{
4445
if (0 === $offset) {

src/AbstractValuedResponse.php

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function offsetExists($offset): bool
3838
* @param mixed $offset
3939
* @return \DCarbone\PHPConsulAPI\Error|mixed|null
4040
*/
41+
#[\ReturnTypeWillChange]
4142
public function offsetGet($offset)
4243
{
4344
if (0 === $offset) {

src/AbstractValuedWriteResponse.php

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function offsetExists($offset): bool
3939
* @param mixed $offset
4040
* @return \DCarbone\PHPConsulAPI\Error|\DCarbone\PHPConsulAPI\WriteMeta|mixed|null
4141
*/
42+
#[\ReturnTypeWillChange]
4243
public function offsetGet($offset)
4344
{
4445
if (0 === $offset) {

src/FakeSlice.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public function append($value): void
7373
/**
7474
* @return \DCarbone\PHPConsulAPI\AbstractModel|false
7575
*/
76+
#[\ReturnTypeWillChange]
7677
public function current()
7778
{
7879
return current($this->_list);
@@ -86,7 +87,7 @@ public function next(): void
8687
/**
8788
* @return int|null
8889
*/
89-
public function key()
90+
public function key(): ?int
9091
{
9192
return key($this->_list);
9293
}
@@ -108,7 +109,7 @@ public function rewind(): void
108109
* @param mixed $offset
109110
* @return bool
110111
*/
111-
public function offsetExists($offset)
112+
public function offsetExists($offset): bool
112113
{
113114
return \is_int($offset) && isset($this->_list[$offset]);
114115
}
@@ -117,7 +118,7 @@ public function offsetExists($offset)
117118
* @param mixed $offset
118119
* @return \DCarbone\PHPConsulAPI\AbstractModel|null
119120
*/
120-
public function offsetGet($offset)
121+
public function offsetGet($offset): ?AbstractModel
121122
{
122123
$this->_validateOffset($offset);
123124
if (isset($this->_list[$offset])) {

src/Values.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ public function toPsr7Array(): array
9999
}
100100

101101
/**
102-
* @return array|string
102+
* @return array
103103
*/
104-
public function current()
104+
public function current(): array
105105
{
106106
return current($this->values);
107107
}
@@ -136,7 +136,7 @@ public function rewind(): void
136136
* @param mixed $offset
137137
* @return bool
138138
*/
139-
public function offsetExists($offset)
139+
public function offsetExists($offset): bool
140140
{
141141
return isset($this->values[$offset]);
142142
}
@@ -145,7 +145,7 @@ public function offsetExists($offset)
145145
* @param string $offset
146146
* @return string
147147
*/
148-
public function offsetGet($offset)
148+
public function offsetGet($offset): string
149149
{
150150
return $this->get($offset);
151151
}
@@ -170,7 +170,7 @@ public function offsetUnset($offset): void
170170
/**
171171
* @return array
172172
*/
173-
public function jsonSerialize()
173+
public function jsonSerialize(): array
174174
{
175175
return $this->values;
176176
}

0 commit comments

Comments
 (0)