Adapted for 5.4.2 from upstream: From 57b6c4366da680dbde339393edb3055c0ca6311d Mon Sep 17 00:00:00 2001 From: William Desportes Date: Tue, 17 Aug 2021 00:11:59 +0200 Subject: [PATCH] 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 --- src/TokensList.php | 4 ++++ src/UtfString.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/TokensList.php b/src/TokensList.php index 486e3aa6..7b63a045 100644 --- a/src/TokensList.php +++ b/src/TokensList.php @@ -153,6 +153,7 @@ public function getNextOfTypeAndValue($type, $value) * @param int $offset the offset to be set * @param Token $value the token to be saved */ + #[ReturnTypeWillChange] public function offsetSet($offset, $value) { if ($offset === null) { @@ -169,6 +170,7 @@ public function offsetSet($offset, $value) * * @return Token */ + #[ReturnTypeWillChange] public function offsetGet($offset) { return $offset < $this->count ? $this->tokens[$offset] : null; @@ -181,6 +183,7 @@ public function offsetGet($offset) * * @return bool */ + #[ReturnTypeWillChange] public function offsetExists($offset) { return $offset < $this->count; @@ -191,6 +194,7 @@ public function offsetExists($offset) * * @param int $offset the offset to be unset */ + #[ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->tokens[$offset]); diff --git a/src/UtfString.php b/src/UtfString.php index 217d1989..ee6e21f0 100644 --- a/src/UtfString.php +++ b/src/UtfString.php @@ -91,6 +91,7 @@ public function __construct($str) * * @return bool */ + #[ReturnTypeWillChange] public function offsetExists($offset) { return ($offset >= 0) && ($offset < $this->charLen); @@ -103,6 +104,7 @@ public function offsetExists($offset) * * @return string|null */ + #[ReturnTypeWillChange] public function offsetGet($offset) { if (($offset < 0) || ($offset >= $this->charLen)) { @@ -146,6 +148,7 @@ public function offsetGet($offset) * * @throws Exception not implemented. */ + #[ReturnTypeWillChange] public function offsetSet($offset, $value) { throw new Exception('Not implemented.'); @@ -158,6 +161,7 @@ public function offsetSet($offset, $value) * * @throws Exception not implemented. */ + #[ReturnTypeWillChange] public function offsetUnset($offset) { throw new Exception('Not implemented.'); From ed900e5b219b13c62dd260fd03ff65c31723d385 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sun, 5 Sep 2021 21:58:36 +0200 Subject: [PATCH] Use fully qualified syntax for "#[\ReturnTypeWillChange]" Ref: 644f6bea450d5d22cb7c7c7991698d9d7945756b Signed-off-by: William Desportes --- src/TokensList.php | 9 ++++----- src/UtfString.php | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/TokensList.php b/src/TokensList.php index bdc520c5..21cac879 100644 --- a/src/TokensList.php +++ b/src/TokensList.php @@ -154,7 +153,7 @@ public function getNextOfTypeAndValue($type, $value) * @param int $offset the offset to be set * @param Token $value the token to be saved */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if ($offset === null) { @@ -171,7 +170,7 @@ public function offsetSet($offset, $value) * * @return Token */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $offset < $this->count ? $this->tokens[$offset] : null; @@ -184,7 +183,7 @@ public function offsetGet($offset) * * @return bool */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function offsetExists($offset) { return $offset < $this->count; @@ -195,7 +194,7 @@ public function offsetExists($offset) * * @param int $offset the offset to be unset */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->tokens[$offset]); diff --git a/src/UtfString.php b/src/UtfString.php index 548aa28f..ffd89323 100644 --- a/src/UtfString.php +++ b/src/UtfString.php @@ -92,7 +91,7 @@ public function __construct($str) * * @return bool */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function offsetExists($offset) { return ($offset >= 0) && ($offset < $this->charLen); @@ -105,7 +104,7 @@ public function offsetExists($offset) * * @return string|null */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function offsetGet($offset) { if (($offset < 0) || ($offset >= $this->charLen)) { @@ -149,7 +148,7 @@ public function offsetGet($offset) * * @throws Exception not implemented. */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { throw new Exception('Not implemented.'); @@ -162,7 +161,7 @@ public function offsetSet($offset, $value) * * @throws Exception not implemented. */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function offsetUnset($offset) { throw new Exception('Not implemented.');