From 93c9753c539b68299a9794569f5a2a982287cbdf Mon Sep 17 00:00:00 2001 From: Arjan Vlek Date: Wed, 3 Aug 2022 10:09:37 +0200 Subject: [PATCH] Fix deprecation warnings on PHP 8.1 If running on PHP 8.1, we would get deprecation messages like ``` PHP Deprecated: Return type of SPSS\Sav\Record\Info::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in {...}/vendor/tiamo/spss/src/Sav/Record/Info.php on line 55 ``` By adding a `#[\ReturnTypeWillChange]` attribute, we remain compatible with PHP 5.6+ but don't get deprecation warnings on 8.1. --- src/Sav/Record/Document.php | 4 ++++ src/Sav/Record/Info.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Sav/Record/Document.php b/src/Sav/Record/Document.php index ea3748d..23818d4 100644 --- a/src/Sav/Record/Document.php +++ b/src/Sav/Record/Document.php @@ -55,6 +55,7 @@ public function append($lines) * * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->lines[$offset]); @@ -65,6 +66,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->lines[$offset]; @@ -74,6 +76,7 @@ public function offsetGet($offset) * @param mixed $offset * @param mixed $value */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { $this->lines[$offset] = $value; @@ -82,6 +85,7 @@ public function offsetSet($offset, $value) /** * @param mixed $offset */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->lines[$offset]); diff --git a/src/Sav/Record/Info.php b/src/Sav/Record/Info.php index e53e2f8..8b98d0e 100644 --- a/src/Sav/Record/Info.php +++ b/src/Sav/Record/Info.php @@ -52,6 +52,7 @@ public function toArray() * * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->data[$offset]); @@ -62,6 +63,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->data[$offset]; @@ -71,6 +73,7 @@ public function offsetGet($offset) * @param mixed $offset * @param mixed $value */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (null === $offset) { @@ -83,6 +86,7 @@ public function offsetSet($offset, $value) /** * @param mixed $offset */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->data[$offset]);