Skip to content

Commit 57b6c43

Browse files
committed
Fix PHP 8.1 fatal errors on classes that "implements ArrayAccess"
"PHP Fatal error: During inheritance of ArrayAccess: Uncaught Return type of PhpMyAdmin\SqlParser\TokensList::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice" "Fatal error: During inheritance of ArrayAccess: Uncaught Return type of PhpMyAdmin\SqlParser\TokensList::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice" I added "#[ReturnTypeWillChange]" Signed-off-by: William Desportes <williamdes@wdes.fr>
1 parent 8c657ba commit 57b6c43

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/TokensList.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public function getNextOfTypeAndValue($type, $value)
153153
* @param int $offset the offset to be set
154154
* @param Token $value the token to be saved
155155
*/
156+
#[ReturnTypeWillChange]
156157
public function offsetSet($offset, $value)
157158
{
158159
if ($offset === null) {
@@ -169,6 +170,7 @@ public function offsetSet($offset, $value)
169170
*
170171
* @return Token
171172
*/
173+
#[ReturnTypeWillChange]
172174
public function offsetGet($offset)
173175
{
174176
return $offset < $this->count ? $this->tokens[$offset] : null;
@@ -181,6 +183,7 @@ public function offsetGet($offset)
181183
*
182184
* @return bool
183185
*/
186+
#[ReturnTypeWillChange]
184187
public function offsetExists($offset)
185188
{
186189
return $offset < $this->count;
@@ -191,6 +194,7 @@ public function offsetExists($offset)
191194
*
192195
* @param int $offset the offset to be unset
193196
*/
197+
#[ReturnTypeWillChange]
194198
public function offsetUnset($offset)
195199
{
196200
unset($this->tokens[$offset]);

src/UtfString.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public function __construct($str)
9191
*
9292
* @return bool
9393
*/
94+
#[ReturnTypeWillChange]
9495
public function offsetExists($offset)
9596
{
9697
return ($offset >= 0) && ($offset < $this->charLen);
@@ -103,6 +104,7 @@ public function offsetExists($offset)
103104
*
104105
* @return string|null
105106
*/
107+
#[ReturnTypeWillChange]
106108
public function offsetGet($offset)
107109
{
108110
if (($offset < 0) || ($offset >= $this->charLen)) {
@@ -146,6 +148,7 @@ public function offsetGet($offset)
146148
*
147149
* @throws Exception not implemented.
148150
*/
151+
#[ReturnTypeWillChange]
149152
public function offsetSet($offset, $value)
150153
{
151154
throw new Exception('Not implemented.');
@@ -158,6 +161,7 @@ public function offsetSet($offset, $value)
158161
*
159162
* @throws Exception not implemented.
160163
*/
164+
#[ReturnTypeWillChange]
161165
public function offsetUnset($offset)
162166
{
163167
throw new Exception('Not implemented.');

0 commit comments

Comments
 (0)