From 01ebc410441ae59c684381c175217281c2d78edd Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Fri, 10 Mar 2023 18:45:14 +0000
Subject: [PATCH] return type adjustments, fixes #2290

Closes #2290

Merge request studip/studip!1514
---
 lib/activities/Stream.php                     | 20 ++++-
 lib/classes/Config.class.php                  | 26 ++++++
 lib/classes/I18NString.php                    |  3 +
 .../Middlewares/StudipMockNavigation.php      | 19 ++++-
 lib/classes/MultiDimArrayObject.class.php     | 11 ++-
 lib/classes/Request.class.php                 | 15 ++++
 lib/classes/SemClass.class.php                | 12 +++
 lib/classes/SemType.class.php                 | 17 +++-
 lib/classes/SessionDecoder.class.php          | 82 +++++++++++++++----
 lib/classes/StudipArrayObject.class.php       | 18 ++++
 lib/classes/StudipCachedArray.php             |  3 +
 lib/classes/StudipPDO.class.php               | 17 +++-
 lib/classes/StudipPDOStatement.php            |  3 +
 lib/classes/UserDataAdapter.php               | 22 ++++-
 lib/classes/restapi/Response.php              | 20 +++++
 lib/classes/sidebar/LinkElement.php           | 19 +++++
 lib/filesystem/StandardFile.php               | 12 +++
 lib/filesystem/UnknownFileType.php            | 12 +++
 lib/models/DataField.class.php                |  3 +
 lib/models/SimpleCollection.class.php         |  9 ++
 lib/models/SimpleORMap.class.php              | 20 ++++-
 lib/models/SimpleORMapCollection.class.php    |  3 +
 lib/navigation/Navigation.php                 |  3 +
 23 files changed, 340 insertions(+), 29 deletions(-)

diff --git a/lib/activities/Stream.php b/lib/activities/Stream.php
index c63e238f4c9..6b64eff6cfb 100644
--- a/lib/activities/Stream.php
+++ b/lib/activities/Stream.php
@@ -79,7 +79,10 @@ class Stream implements \ArrayAccess, \Countable, \IteratorAggregate
 
     /**
      * ArrayAccess: Check whether the given offset exists.
+     *
+     * @todo Add bool return type when Stud.IP requires PHP8 minimal
      */
+    #[\ReturnTypeWillChange]
     public function offsetExists($offset)
     {
         return isset($this->activities[$offset]);
@@ -87,7 +90,10 @@ class Stream implements \ArrayAccess, \Countable, \IteratorAggregate
 
     /**
      * ArrayAccess: Get the value at the given offset.
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
      */
+    #[\ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         return $this->activities[$offset];
@@ -95,7 +101,10 @@ class Stream implements \ArrayAccess, \Countable, \IteratorAggregate
 
     /**
      * ArrayAccess: Set the value at the given offset.
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[\ReturnTypeWillChange]
     public function offsetSet($offset, $value)
     {
         $this->activities[$offset] = $value;
@@ -103,7 +112,10 @@ class Stream implements \ArrayAccess, \Countable, \IteratorAggregate
 
     /**
      * ArrayAccess: unset the value at the given offset (not applicable)
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[\ReturnTypeWillChange]
     public function offsetUnset($offset)
     {
         unset($this->activities[$offset]);
@@ -111,7 +123,10 @@ class Stream implements \ArrayAccess, \Countable, \IteratorAggregate
 
     /**
      * IteratorAggregate
+     *
+     * @todo Add \Traversable return type when Stud.IP requires PHP8 minimal
      */
+    #[\ReturnTypeWillChange]
     public function getIterator()
     {
         return new \ArrayIterator($this->activities);
@@ -119,10 +134,13 @@ class Stream implements \ArrayAccess, \Countable, \IteratorAggregate
 
     /**
      * Countable
+     *
+     * @todo Add int return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function count()
     {
-        return sizeof($this->activities);
+        return count($this->activities);
     }
 
     /**
diff --git a/lib/classes/Config.class.php b/lib/classes/Config.class.php
index f977bb9d5c3..4d57f0f3338 100644
--- a/lib/classes/Config.class.php
+++ b/lib/classes/Config.class.php
@@ -153,11 +153,15 @@ class Config implements ArrayAccess, Countable, IteratorAggregate
 
     /**
      * IteratorAggregate
+     *
+     * @todo Add Traversable return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function getIterator()
     {
         return new ArrayIterator($this->data);
     }
+
     /**
      * magic method for dynamic properties
      */
@@ -165,6 +169,7 @@ class Config implements ArrayAccess, Countable, IteratorAggregate
     {
         return $this->getValue($field);
     }
+
     /**
      * magic method for dynamic properties
      */
@@ -172,6 +177,7 @@ class Config implements ArrayAccess, Countable, IteratorAggregate
     {
          return $this->setValue($field, $value);
     }
+
     /**
      * magic method for dynamic properties
      */
@@ -179,37 +185,57 @@ class Config implements ArrayAccess, Countable, IteratorAggregate
     {
         return isset($this->data[$field]);
     }
+
     /**
      * ArrayAccess: Check whether the given offset exists.
+     *
+     * @todo Add bool return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetExists($offset)
     {
         return isset($this->$offset);
     }
+
     /**
      * ArrayAccess: Get the value at the given offset.
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         return $this->$offset;
     }
+
     /**
      * ArrayAccess: Set the value at the given offset.
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetSet($offset, $value)
     {
         $this->$offset = $value;
     }
+
     /**
      * ArrayAccess: unset the value at the given offset (not applicable)
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetUnset($offset)
     {
 
     }
+
     /**
      * Countable
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function count()
     {
         return count($this->data);
diff --git a/lib/classes/I18NString.php b/lib/classes/I18NString.php
index 63c8ba64766..353062eebd0 100644
--- a/lib/classes/I18NString.php
+++ b/lib/classes/I18NString.php
@@ -80,7 +80,10 @@ class I18NString implements JsonSerializable
      * Return the JSON representation of this i18n field in selected language.
      *
      * @return string
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function jsonSerialize()
     {
         return (string) $this;
diff --git a/lib/classes/JsonApi/Middlewares/StudipMockNavigation.php b/lib/classes/JsonApi/Middlewares/StudipMockNavigation.php
index 0bce8a41fd8..34225d4ad83 100644
--- a/lib/classes/JsonApi/Middlewares/StudipMockNavigation.php
+++ b/lib/classes/JsonApi/Middlewares/StudipMockNavigation.php
@@ -18,7 +18,10 @@ class DummyNavigation extends \Navigation implements \ArrayAccess
 
     /**
      * ArrayAccess: Check whether the given offset exists.
+     *
+     * @todo Add bool return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetExists($offset)
     {
         return true;
@@ -26,7 +29,10 @@ class DummyNavigation extends \Navigation implements \ArrayAccess
 
     /**
      * ArrayAccess: Get the value at the given offset.
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
      */
+    #[\ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         return $this;
@@ -34,21 +40,30 @@ class DummyNavigation extends \Navigation implements \ArrayAccess
 
     /**
      * ArrayAccess: Set the value at the given offset.
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[\ReturnTypeWillChange]
     public function offsetSet($offset, $value)
     {
     }
 
     /**
      * ArrayAccess: Delete the value at the given offset.
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[\ReturnTypeWillChange]
     public function offsetUnset($offset)
     {
     }
 
     /**
      * IteratorAggregate: Create interator for request parameters.
+     *
+     * @todo Add \Traversable return type when Stud.IP requires PHP8 minimal
      */
+    #[\ReturnTypeWillChange]
     public function getIterator()
     {
         return new \ArrayIterator();
@@ -58,8 +73,8 @@ class DummyNavigation extends \Navigation implements \ArrayAccess
 class StudipMockNavigation
 {
     /**
-     * @param Request                 $request das PSR-7 Request-Objekt
-     * @param RequestHandlerInterface $handler das PSR-7 Response-Objekt
+     * @param Request        $request das PSR-7 Request-Objekt
+     * @param RequestHandler $handler das PSR-7 Response-Objekt
      *
      * @return ResponseInterface die neue Response
      */
diff --git a/lib/classes/MultiDimArrayObject.class.php b/lib/classes/MultiDimArrayObject.class.php
index 8af74a7ea74..459578f5ca6 100644
--- a/lib/classes/MultiDimArrayObject.class.php
+++ b/lib/classes/MultiDimArrayObject.class.php
@@ -80,7 +80,10 @@ class MultiDimArrayObject extends StudipArrayObject
      * Create a new iterator from an ArrayObject instance
      *
      * @return \Iterator
+     *
+     * @todo Add Traversable return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function getIterator()
     {
         $class = $this->iteratorClass;
@@ -94,7 +97,10 @@ class MultiDimArrayObject extends StudipArrayObject
      * @param  mixed $key
      * @param  mixed $value
      * @return void
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetSet($key, $value)
     {
         $new_value = $this->recursiveArrayToArrayObjects($value);
@@ -103,9 +109,10 @@ class MultiDimArrayObject extends StudipArrayObject
             $new_value = new $class($new_value, $this->getFlags(), $this->getIteratorClass());
         }
         if (is_null($key)) {
-            return $this->storage[] = $new_value;
+            $this->storage[] = $new_value;
+        } else {
+            $this->storage[$key] = $new_value;
         }
-        $this->storage[$key] = $new_value;
     }
 
     protected function recursiveArrayToArrayObjects($data)
diff --git a/lib/classes/Request.class.php b/lib/classes/Request.class.php
index 74b0a8a10f7..27ed629595d 100644
--- a/lib/classes/Request.class.php
+++ b/lib/classes/Request.class.php
@@ -45,7 +45,10 @@ class Request implements ArrayAccess, IteratorAggregate
 
     /**
      * ArrayAccess: Check whether the given offset exists.
+     *
+     * @todo Add bool return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetExists($offset)
     {
         return isset($this->params[$offset]);
@@ -53,7 +56,10 @@ class Request implements ArrayAccess, IteratorAggregate
 
     /**
      * ArrayAccess: Get the value at the given offset.
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         return $this->params[$offset] ?? null;
@@ -61,7 +67,10 @@ class Request implements ArrayAccess, IteratorAggregate
 
     /**
      * ArrayAccess: Set the value at the given offset.
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetSet($offset, $value)
     {
         $this->params[$offset] = $value;
@@ -69,7 +78,10 @@ class Request implements ArrayAccess, IteratorAggregate
 
     /**
      * ArrayAccess: Delete the value at the given offset.
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetUnset($offset)
     {
         unset($this->params[$offset]);
@@ -77,7 +89,10 @@ class Request implements ArrayAccess, IteratorAggregate
 
     /**
      * IteratorAggregate: Create interator for request parameters.
+     *
+     * @todo Add Traversable return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function getIterator()
     {
         return new ArrayIterator((array)$this->params);
diff --git a/lib/classes/SemClass.class.php b/lib/classes/SemClass.class.php
index b6ccb82e990..862747f0696 100644
--- a/lib/classes/SemClass.class.php
+++ b/lib/classes/SemClass.class.php
@@ -488,7 +488,10 @@ class SemClass implements ArrayAccess
      * deprecated, does nothing, should not be used
      * @param string $offset
      * @param mixed $value
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetSet($offset, $value)
     {
     }
@@ -498,7 +501,10 @@ class SemClass implements ArrayAccess
      * new array-structure to the old boolean values.
      * @param integer $offset: name of attribute
      * @return boolean|(localized)string
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         switch ($offset) {
@@ -533,7 +539,10 @@ class SemClass implements ArrayAccess
      * ArrayAccess method to check if an attribute exists.
      * @param int $offset
      * @return bool
+     *
+     * @todo Add bool return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetExists($offset)
     {
         return isset($this->data[$offset]);
@@ -542,7 +551,10 @@ class SemClass implements ArrayAccess
     /**
      * deprecated, does nothing, should not be used
      * @param string $offset
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetUnset($offset)
     {
     }
diff --git a/lib/classes/SemType.class.php b/lib/classes/SemType.class.php
index 0db463ac2b2..88244065edf 100644
--- a/lib/classes/SemType.class.php
+++ b/lib/classes/SemType.class.php
@@ -119,7 +119,10 @@ class SemType implements ArrayAccess
      * deprecated, does nothing, should not be used
      * @param string $offset
      * @param mixed $value
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetSet($offset, $value)
     {
     }
@@ -129,7 +132,10 @@ class SemType implements ArrayAccess
      * new array-structure to the old boolean values.
      * @param integer $offset: name of attribute
      * @return boolean|(localized)string
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         switch ($offset) {
@@ -146,9 +152,12 @@ class SemType implements ArrayAccess
 
     /**
      * ArrayAccess method to check if an attribute exists.
-     * @param type $offset
-     * @return type
+     * @param mixed $offset
+     * @return bool
+     *
+     * @todo Add bool return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetExists($offset)
     {
         return isset($this->data[$offset]);
@@ -157,7 +166,10 @@ class SemType implements ArrayAccess
     /**
      * deprecated, does nothing, should not be used
      * @param string $offset
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetUnset($offset)
     {
     }
@@ -256,4 +268,3 @@ class SemType implements ArrayAccess
     }
 
 }
-
diff --git a/lib/classes/SessionDecoder.class.php b/lib/classes/SessionDecoder.class.php
index c6715cd4265..8c0bc6b9c7d 100644
--- a/lib/classes/SessionDecoder.class.php
+++ b/lib/classes/SessionDecoder.class.php
@@ -83,44 +83,98 @@ class SessionDecoder implements ArrayAccess, Countable, Iterator {
         return $this->var_names;
     }
 
-    public function rewind() {
+    /**
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
+    public function rewind()
+    {
         reset($this->var_names);
     }
 
-    public function current() {
+    /**
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
+    public function current()
+    {
         $current = current($this->var_names);
         return $current !== false ? $this->offsetGet($current) : false;
     }
 
-    public function key() {
+    /**
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
+    public function key()
+    {
         return current($this->var_names);
     }
 
-    public function next() {
-        $next = next($this->var_names);
-        return $this->current();
+    /**
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
+    public function next()
+    {
+        next($this->var_names);
     }
 
-    public function valid() {
+    /**
+     * @todo Add bool return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
+    public function valid()
+    {
         $current = current($this->var_names);
         return $current !== false;
     }
 
-    public function offsetExists($offset){
+    /**
+     * @todo Add bool return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
+    public function offsetExists($offset)
+    {
         return isset($this->encoded_session[$offset]);
     }
 
-    public function offsetGet($offset){
-        if($this->offsetExists($offset) && !isset($this->decoded_session[$offset])){
+    /**
+     * @param $offset
+     * @return mixed|null
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
+    public function offsetGet($offset)
+    {
+        if($this->offsetExists($offset) && !isset($this->decoded_session[$offset])) {
             $this->decoded_session[$offset] = unserialize($this->encoded_session[$offset]);
         }
-        return isset($this->decoded_session[$offset]) ? $this->decoded_session[$offset] : null;
+        return $this->decoded_session[$offset] ?? null;
     }
 
-    public function offsetSet($offset, $value) {}
-    public function offsetUnset($offset) {}
+    /**
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
+    public function offsetSet($offset, $value)
+    {
+    }
 
-    public function count(){
+    /**
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
+    public function offsetUnset($offset)
+    {
+    }
+
+    /**
+     * @todo Add int return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
+    public function count()
+    {
         return count($this->var_names);
     }
 
diff --git a/lib/classes/StudipArrayObject.class.php b/lib/classes/StudipArrayObject.class.php
index f025ffbb8b8..fe9aad17622 100644
--- a/lib/classes/StudipArrayObject.class.php
+++ b/lib/classes/StudipArrayObject.class.php
@@ -159,7 +159,10 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
      * Get the number of public properties in the ArrayObject
      *
      * @return int
+     *
+     * @todo Add int return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function count()
     {
         return count($this->storage);
@@ -215,7 +218,10 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
      * Create a new iterator from an ArrayObject instance
      *
      * @return \Iterator
+     *
+     * @todo Add Traversable return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function getIterator()
     {
         $class = $this->iteratorClass;
@@ -268,7 +274,10 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
      *
      * @param  mixed $key
      * @return bool
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetExists($key)
     {
         return isset($this->storage[$key]);
@@ -279,7 +288,10 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
      *
      * @param  mixed $key
      * @return mixed
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetGet($key)
     {
         $ret = null;
@@ -297,7 +309,10 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
      * @param  mixed $key
      * @param  mixed $value
      * @return void
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetSet($key, $value)
     {
         if (is_null($key)) {
@@ -312,7 +327,10 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
      *
      * @param  mixed $key
      * @return void
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetUnset($key)
     {
         if ($this->offsetExists($key)) {
diff --git a/lib/classes/StudipCachedArray.php b/lib/classes/StudipCachedArray.php
index 830128dde4d..18bb55b7086 100644
--- a/lib/classes/StudipCachedArray.php
+++ b/lib/classes/StudipCachedArray.php
@@ -73,7 +73,10 @@ class StudipCachedArray implements ArrayAccess
      * @param string $offset Offset
      *
      * @return mixed
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         $this->loadData($offset);
diff --git a/lib/classes/StudipPDO.class.php b/lib/classes/StudipPDO.class.php
index a758b1028df..3fe07188efb 100644
--- a/lib/classes/StudipPDO.class.php
+++ b/lib/classes/StudipPDO.class.php
@@ -123,8 +123,11 @@ class StudipPDO extends PDO
      *
      * @param mixed $value PHP value to quote
      * @param ?int $type parameter type (e.g. PDO::PARAM_STR)
-     * @return string quoted SQL string
+     * @return string|false quoted SQL string
+     *
+     * @todo Add string|false return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function quote($value, $type = null)
     {
         if (!isset($type)) {
@@ -161,8 +164,11 @@ class StudipPDO extends PDO
      * Executes an SQL statement and returns the number of affected rows.
      *
      * @param string    SQL statement
-     * @return int      number of affected rows
+     * @return int|false      number of affected rows
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function exec($statement)
     {
         $this->verify($statement);
@@ -195,9 +201,12 @@ class StudipPDO extends PDO
     /**
      * Prepares a statement for execution and returns a statement object.
      *
-     * @param string    SQL statement
-     * @return object   PDOStatement object
+     * @param string $statement SQL statement
+     * @param array  $driver_options
+     *
+     * @return StudipPDOStatement
      */
+    #[ReturnTypeWillChange]
     public function prepare($statement, $driver_options = [])
     {
         $this->verify($statement);
diff --git a/lib/classes/StudipPDOStatement.php b/lib/classes/StudipPDOStatement.php
index 5aab1cc807e..4a3d0697de6 100644
--- a/lib/classes/StudipPDOStatement.php
+++ b/lib/classes/StudipPDOStatement.php
@@ -99,7 +99,10 @@ class StudipPDOStatement implements IteratorAggregate
 
     /**
      * Forwards all Iterator methods to the actual statement object.
+     *
+     * @todo Add Traversable return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function getIterator()
     {
         return $this->stmt;
diff --git a/lib/classes/UserDataAdapter.php b/lib/classes/UserDataAdapter.php
index db9361919c7..0a0c3beab2b 100644
--- a/lib/classes/UserDataAdapter.php
+++ b/lib/classes/UserDataAdapter.php
@@ -26,7 +26,10 @@ class UserDataAdapter implements ArrayAccess, Countable, IteratorAggregate
 
     /**
      * ArrayAccess: Check whether the given offset exists.
+     *
+     * @todo Add bool return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetExists($offset)
     {
         return $this->user->offsetExists($this->adaptOffset($offset));
@@ -34,7 +37,10 @@ class UserDataAdapter implements ArrayAccess, Countable, IteratorAggregate
 
     /**
      * ArrayAccess: Get the value at the given offset.
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         return $this->user->offsetGet($this->adaptOffset($offset));
@@ -42,23 +48,32 @@ class UserDataAdapter implements ArrayAccess, Countable, IteratorAggregate
 
     /**
      * ArrayAccess: Set the value at the given offset.
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetSet($offset, $value)
     {
-        return $this->user->offsetSet($this->adaptOffset($offset), $value);
+        $this->user->offsetSet($this->adaptOffset($offset), $value);
     }
 
     /**
      * ArrayAccess: unset the value at the given offset.
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetUnset($offset)
     {
-        return $this->user->offsetUnset($this->adaptOffset($offset));
+        $this->user->offsetUnset($this->adaptOffset($offset));
     }
 
     /**
      * @see Countable::count()
+     *
+     * @todo Add int return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function count()
     {
         return $this->user->count();
@@ -66,7 +81,10 @@ class UserDataAdapter implements ArrayAccess, Countable, IteratorAggregate
 
     /**
      * @see IteratorAggregate::getIterator()
+     *
+     * @todo Add Traversable return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function getIterator()
     {
         return $this->user->getIterator();
diff --git a/lib/classes/restapi/Response.php b/lib/classes/restapi/Response.php
index d8ee92038cf..08a23d4792d 100644
--- a/lib/classes/restapi/Response.php
+++ b/lib/classes/restapi/Response.php
@@ -122,21 +122,41 @@ class Response implements \ArrayAccess
     }
 
     // array access methods for headers
+
+    /**
+     * @todo Add bool return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
     public function offsetExists($offset)
     {
         return isset($this->headers[$offset]);
     }
 
+    /**
+     * @param $offset
+     * @return mixed
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
+     */
+    #[\ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         return @$this->headers[$offset];
     }
 
+    /**
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
     public function offsetSet($offset, $value)
     {
         $this->headers[$offset] = $value;
     }
 
+    /**
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
     public function offsetUnset($offset)
     {
         unset($this->headers[$offset]);
diff --git a/lib/classes/sidebar/LinkElement.php b/lib/classes/sidebar/LinkElement.php
index 8b20dbea8f7..8e3e2706e11 100644
--- a/lib/classes/sidebar/LinkElement.php
+++ b/lib/classes/sidebar/LinkElement.php
@@ -247,21 +247,40 @@ class LinkElement extends WidgetElement implements ArrayAccess
 
     // Array access for attributes
 
+    /**
+     * @todo Add bool return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
     public function offsetExists($offset)
     {
         return isset($this->attributes[$offset]);
     }
 
+    /**
+     * @param $offset
+     * @return mixed
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         return $this->attributes[$offset];
     }
 
+    /**
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
     public function offsetSet($offset, $value)
     {
         $this->attributes[$offset] = $value;
     }
 
+    /**
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
+     */
+    #[ReturnTypeWillChange]
     public function offsetUnset($offset)
     {
         unset($this->attributes[$offset]);
diff --git a/lib/filesystem/StandardFile.php b/lib/filesystem/StandardFile.php
index c11541066be..371f0416691 100644
--- a/lib/filesystem/StandardFile.php
+++ b/lib/filesystem/StandardFile.php
@@ -112,7 +112,10 @@ class StandardFile implements FileType, ArrayAccess, StandardFileInterface
 
     /**
      * ArrayAccess: Check whether the given offset exists.
+     *
+     * @todo Add bool return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetExists($offset)
     {
         return $this->__isset($offset);
@@ -120,7 +123,10 @@ class StandardFile implements FileType, ArrayAccess, StandardFileInterface
 
     /**
      * ArrayAccess: Get the value at the given offset.
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         return $this->__get($offset);
@@ -128,7 +134,10 @@ class StandardFile implements FileType, ArrayAccess, StandardFileInterface
 
     /**
      * ArrayAccess: Set the value at the given offset.
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetSet($offset, $value)
     {
         $this->__set($offset, $value);
@@ -136,7 +145,10 @@ class StandardFile implements FileType, ArrayAccess, StandardFileInterface
 
     /**
      * ArrayAccess: unset the value at the given offset (not applicable)
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetUnset($offset)
     {
 
diff --git a/lib/filesystem/UnknownFileType.php b/lib/filesystem/UnknownFileType.php
index 15c2b92e13f..bfd00ba119f 100644
--- a/lib/filesystem/UnknownFileType.php
+++ b/lib/filesystem/UnknownFileType.php
@@ -51,7 +51,10 @@ class UnknownFileType implements FileType, ArrayAccess
 
     /**
      * ArrayAccess: Check whether the given offset exists.
+     *
+     * @todo Add bool return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetExists($offset)
     {
         return $this->__isset($offset);
@@ -59,7 +62,10 @@ class UnknownFileType implements FileType, ArrayAccess
 
     /**
      * ArrayAccess: Get the value at the given offset.
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         return $this->__get($offset);
@@ -67,7 +73,10 @@ class UnknownFileType implements FileType, ArrayAccess
 
     /**
      * ArrayAccess: Set the value at the given offset.
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetSet($offset, $value)
     {
         $this->__set($offset, $value);
@@ -75,7 +84,10 @@ class UnknownFileType implements FileType, ArrayAccess
 
     /**
      * ArrayAccess: unset the value at the given offset (not applicable)
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetUnset($offset)
     {
 
diff --git a/lib/models/DataField.class.php b/lib/models/DataField.class.php
index 43a6bb3ae05..ae7b7ac5d63 100644
--- a/lib/models/DataField.class.php
+++ b/lib/models/DataField.class.php
@@ -254,7 +254,10 @@ class DataField extends SimpleORMap implements PrivacyObject
      * Specialized count method that returns the number of concrete entries.
      *
      * @return int number of entries
+     *
+     * @todo Add int return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function count()
     {
         return DatafieldEntryModel::countBySQL('datafield_id = ?', [$this->id]);
diff --git a/lib/models/SimpleCollection.class.php b/lib/models/SimpleCollection.class.php
index 26439b233f0..11dd2965301 100644
--- a/lib/models/SimpleCollection.class.php
+++ b/lib/models/SimpleCollection.class.php
@@ -292,9 +292,15 @@ class SimpleCollection extends StudipArrayObject
      * Sets the value at the specified index
      * ensures the value has ArrayAccess
      *
+     * @param mixed $index
+     * @param mixed $newval
+     *
      * @see ArrayObject::offsetSet()
      * @return void
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetSet($index, $newval)
     {
         if (is_numeric($index)) {
@@ -309,7 +315,10 @@ class SimpleCollection extends StudipArrayObject
      *
      * @see ArrayObject::offsetUnset()
      * @throws InvalidArgumentException
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetUnset($index)
     {
         if ($this->offsetExists($index)) {
diff --git a/lib/models/SimpleORMap.class.php b/lib/models/SimpleORMap.class.php
index b210c399320..0488b0fd60f 100644
--- a/lib/models/SimpleORMap.class.php
+++ b/lib/models/SimpleORMap.class.php
@@ -1631,7 +1631,10 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
      *
      * @param string $offset
      * @return bool
+     *
+     * @todo Add bool return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetExists($offset)
     {
         return $this->__isset($offset);
@@ -1644,7 +1647,10 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
      * @throws BadMethodCallException if getter for additional field could not be found
      * @param string $offset the column or additional field
      * @return null|string|SimpleORMapCollection
+     *
+     * @todo Add mixed return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         return $this->getValue($offset);
@@ -1658,7 +1664,10 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
      * @param string $offset
      * @param mixed $value
      * @return void
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetSet($offset, $value)
     {
         $this->setValue($offset, $value);
@@ -1668,7 +1677,10 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
      *
      * @param string $offset
      * @return void
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetUnset($offset)
     {
 
@@ -1676,8 +1688,11 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
     /**
      * IteratorAggregate
      *
-     * @return \ArrayIterator
+     * @return ArrayIterator
+     *
+     * @todo Add Traversable return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function getIterator()
     {
         return new ArrayIterator($this->toArray());
@@ -1686,7 +1701,10 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
      * Countable
      *
      * @return int
+     *
+     * @todo Add int return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function count()
     {
         return count($this->known_slots()) - count($this->relations);
diff --git a/lib/models/SimpleORMapCollection.class.php b/lib/models/SimpleORMapCollection.class.php
index 94a52ecdfd8..11d8a5ffdd1 100644
--- a/lib/models/SimpleORMapCollection.class.php
+++ b/lib/models/SimpleORMapCollection.class.php
@@ -90,7 +90,10 @@ class SimpleORMapCollection extends SimpleCollection
      *
      * @see ArrayObject::offsetSet()
      * @throws InvalidArgumentException if the given model does not fit (wrong type or id)
+     *
+     * @todo Add void return type when Stud.IP requires PHP8 minimal
      */
+    #[ReturnTypeWillChange]
     public function offsetSet($index, $newval)
     {
         if (!is_null($index)) {
diff --git a/lib/navigation/Navigation.php b/lib/navigation/Navigation.php
index 8c30714b5d7..b05cd1d3ed9 100644
--- a/lib/navigation/Navigation.php
+++ b/lib/navigation/Navigation.php
@@ -568,7 +568,10 @@ class Navigation implements IteratorAggregate
 
     /**
      * IteratorAggregate: Create interator for request parameters.
+     *
+     * @todo Add Traversable return type when Stud.IP requires PHP8 minimal
      */
+    #[\ReturnTypeWillChange]
     public function getIterator()
     {
         return new ArrayIterator($this->getSubNavigation());
-- 
GitLab