aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2024-05-06 08:50:32 +0000
committerDavid Siegfried <david.siegfried@uni-vechta.de>2024-05-06 08:50:32 +0000
commitc659d71e33cecbe42a7038c281c082f4b5c98414 (patch)
tree6bb722750e822599723045082449d2e63034dd6f /lib
parentf8d42374860009922ee68bd9aba63e50f66e77df (diff)
adjustments for php8, fixes #4111
Closes #4111 Merge request studip/studip!2956
Diffstat (limited to 'lib')
-rw-r--r--lib/activities/Stream.php30
-rw-r--r--lib/classes/Config.class.php30
-rw-r--r--lib/classes/ForumHelpers.php10
-rw-r--r--lib/classes/I18NString.php7
-rw-r--r--lib/classes/JsonApi/Middlewares/StudipMockNavigation.php27
-rw-r--r--lib/classes/MultiDimArrayObject.class.php13
-rw-r--r--lib/classes/Request.class.php27
-rw-r--r--lib/classes/SemClass.class.php22
-rw-r--r--lib/classes/SemType.class.php27
-rw-r--r--lib/classes/SessionDecoder.class.php61
-rw-r--r--lib/classes/StudipArrayObject.class.php38
-rw-r--r--lib/classes/StudipCachedArray.php7
-rw-r--r--lib/classes/StudipPDO.class.php33
-rw-r--r--lib/classes/StudipPDOStatement.php5
-rw-r--r--lib/classes/UserDataAdapter.php30
-rw-r--r--lib/classes/restapi/Response.php24
-rw-r--r--lib/classes/sidebar/AttributesArrayAccessTrait.php26
-rw-r--r--lib/filesystem/StandardFile.php21
-rw-r--r--lib/filesystem/UnknownFileType.php21
-rw-r--r--lib/models/DataField.class.php5
-rw-r--r--lib/models/SimpleCollection.class.php12
-rw-r--r--lib/models/SimpleORMap.class.php41
-rw-r--r--lib/models/SimpleORMapCollection.class.php5
-rw-r--r--lib/navigation/Navigation.php7
24 files changed, 113 insertions, 416 deletions
diff --git a/lib/activities/Stream.php b/lib/activities/Stream.php
index 6b64eff..b1472ef 100644
--- a/lib/activities/Stream.php
+++ b/lib/activities/Stream.php
@@ -79,66 +79,48 @@ 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)
+ public function offsetExists($offset): bool
{
return isset($this->activities[$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)
+ public function offsetGet($offset): mixed
{
return $this->activities[$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)
+ public function offsetSet($offset, $value): void
{
$this->activities[$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)
+ public function offsetUnset($offset): void
{
unset($this->activities[$offset]);
}
/**
* IteratorAggregate
- *
- * @todo Add \Traversable return type when Stud.IP requires PHP8 minimal
*/
- #[\ReturnTypeWillChange]
- public function getIterator()
+ public function getIterator(): \Traversable
{
return new \ArrayIterator($this->activities);
}
/**
* Countable
- *
- * @todo Add int return type when Stud.IP requires PHP8 minimal
*/
- #[ReturnTypeWillChange]
- public function count()
+ public function count(): int
{
return count($this->activities);
}
diff --git a/lib/classes/Config.class.php b/lib/classes/Config.class.php
index 4d57f0f..2f6b728 100644
--- a/lib/classes/Config.class.php
+++ b/lib/classes/Config.class.php
@@ -153,11 +153,8 @@ class Config implements ArrayAccess, Countable, IteratorAggregate
/**
* IteratorAggregate
- *
- * @todo Add Traversable return type when Stud.IP requires PHP8 minimal
*/
- #[ReturnTypeWillChange]
- public function getIterator()
+ public function getIterator(): Traversable
{
return new ArrayIterator($this->data);
}
@@ -188,55 +185,40 @@ class Config 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)
+ public function offsetExists($offset): bool
{
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)
+ public function offsetGet($offset): mixed
{
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)
+ public function offsetSet($offset, $value): void
{
$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)
+ public function offsetUnset($offset): void
{
}
/**
* Countable
- *
- * @todo Add void return type when Stud.IP requires PHP8 minimal
*/
- #[ReturnTypeWillChange]
- public function count()
+ public function count(): int
{
return count($this->data);
}
diff --git a/lib/classes/ForumHelpers.php b/lib/classes/ForumHelpers.php
index 3054dbc..0c036cf 100644
--- a/lib/classes/ForumHelpers.php
+++ b/lib/classes/ForumHelpers.php
@@ -92,19 +92,15 @@ class ForumHelpers {
*/
public static function translate_perm($perm)
{
- $mapping = [
+ return match ($perm) {
'root' => _('Root'),
'admin' => _('Administrator/-in'),
'dozent' => _('Lehrende/-r'),
'tutor' => _('Tutor/-in'),
'autor' => _('Autor/-in'),
'user' => _('Leser/-in'),
- ];
-
- // TODO: Activate next when devboard reliably runs on PHP7
- // return $mapping[$perm] ?? '';
-
- return isset($mapping[$perm]) ? $mapping[$perm] : '';
+ default => '',
+ };
}
/**
diff --git a/lib/classes/I18NString.php b/lib/classes/I18NString.php
index 63e275e..eab42ff 100644
--- a/lib/classes/I18NString.php
+++ b/lib/classes/I18NString.php
@@ -78,13 +78,8 @@ 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()
+ public function jsonSerialize(): string
{
return (string) $this;
}
diff --git a/lib/classes/JsonApi/Middlewares/StudipMockNavigation.php b/lib/classes/JsonApi/Middlewares/StudipMockNavigation.php
index 34225d4..0883809 100644
--- a/lib/classes/JsonApi/Middlewares/StudipMockNavigation.php
+++ b/lib/classes/JsonApi/Middlewares/StudipMockNavigation.php
@@ -18,53 +18,38 @@ 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)
+ public function offsetExists($offset): bool
{
return true;
}
/**
* ArrayAccess: Get the value at the given offset.
- *
- * @todo Add mixed return type when Stud.IP requires PHP8 minimal
*/
- #[\ReturnTypeWillChange]
- public function offsetGet($offset)
+ public function offsetGet($offset): mixed
{
return $this;
}
/**
* 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)
+ public function offsetSet($offset, $value): void
{
}
/**
* ArrayAccess: Delete the value at the given offset.
- *
- * @todo Add void return type when Stud.IP requires PHP8 minimal
*/
- #[\ReturnTypeWillChange]
- public function offsetUnset($offset)
+ public function offsetUnset($offset): void
{
}
/**
- * IteratorAggregate: Create interator for request parameters.
- *
- * @todo Add \Traversable return type when Stud.IP requires PHP8 minimal
+ * IteratorAggregate: Create iterator for request parameters.
*/
- #[\ReturnTypeWillChange]
- public function getIterator()
+ public function getIterator(): \Traversable
{
return new \ArrayIterator();
}
diff --git a/lib/classes/MultiDimArrayObject.class.php b/lib/classes/MultiDimArrayObject.class.php
index 459578f..b578018 100644
--- a/lib/classes/MultiDimArrayObject.class.php
+++ b/lib/classes/MultiDimArrayObject.class.php
@@ -78,13 +78,8 @@ 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()
+ public function getIterator(): Traversable
{
$class = $this->iteratorClass;
@@ -96,12 +91,8 @@ 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)
+ public function offsetSet($key, $value): void
{
$new_value = $this->recursiveArrayToArrayObjects($value);
if (is_array($new_value)) {
diff --git a/lib/classes/Request.class.php b/lib/classes/Request.class.php
index c977934..d72a6a9 100644
--- a/lib/classes/Request.class.php
+++ b/lib/classes/Request.class.php
@@ -45,55 +45,40 @@ 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)
+ public function offsetExists($offset): bool
{
return isset($this->params[$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)
+ public function offsetGet($offset): mixed
{
return $this->params[$offset] ?? null;
}
/**
* 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)
+ public function offsetSet($offset, $value): void
{
$this->params[$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)
+ public function offsetUnset($offset): void
{
unset($this->params[$offset]);
}
/**
- * IteratorAggregate: Create interator for request parameters.
- *
- * @todo Add Traversable return type when Stud.IP requires PHP8 minimal
+ * IteratorAggregate: Create iterator for request parameters.
*/
- #[ReturnTypeWillChange]
- public function getIterator()
+ public function getIterator(): Traversable
{
return new ArrayIterator((array)$this->params);
}
diff --git a/lib/classes/SemClass.class.php b/lib/classes/SemClass.class.php
index 09580e2..c4a2c26 100644
--- a/lib/classes/SemClass.class.php
+++ b/lib/classes/SemClass.class.php
@@ -478,11 +478,8 @@ 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)
+ public function offsetSet($offset, $value): void
{
}
@@ -490,12 +487,8 @@ class SemClass implements ArrayAccess
* Compatibility function with old $SEM_CLASS variable for plugins. Maps the
* 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)
+ public function offsetGet($offset): mixed
{
switch ($offset) {
case "name":
@@ -528,12 +521,8 @@ 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)
+ public function offsetExists($offset): bool
{
return isset($this->data[$offset]);
}
@@ -541,11 +530,8 @@ 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)
+ public function offsetUnset($offset): void
{
}
diff --git a/lib/classes/SemType.class.php b/lib/classes/SemType.class.php
index 3d5de5d..2365c4e 100644
--- a/lib/classes/SemType.class.php
+++ b/lib/classes/SemType.class.php
@@ -86,8 +86,8 @@ class SemType implements ArrayAccess
if ($this->countSeminars() === 0) {
$db = DBManager::get();
$statement = $db->prepare("
- DELETE FROM sem_types
- WHERE id = :id
+ DELETE FROM sem_types
+ WHERE id = :id
");
StudipCacheFactory::getCache()->expire('DB_SEM_TYPES_ARRAY');
return $statement->execute([
@@ -119,11 +119,9 @@ 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)
+
+ public function offsetSet($offset, $value): void
{
}
@@ -131,12 +129,8 @@ class SemType implements ArrayAccess
* Compatibility function with old $SEM_TYPE variable for plugins. Maps the
* 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)
+ public function offsetGet($offset): mixed
{
switch ($offset) {
case "name":
@@ -153,12 +147,8 @@ class SemType implements ArrayAccess
/**
* ArrayAccess method to check if an attribute exists.
* @param mixed $offset
- * @return bool
- *
- * @todo Add bool return type when Stud.IP requires PHP8 minimal
*/
- #[ReturnTypeWillChange]
- public function offsetExists($offset)
+ public function offsetExists($offset): bool
{
return isset($this->data[$offset]);
}
@@ -166,11 +156,8 @@ 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)
+ public function offsetUnset($offset): void
{
}
diff --git a/lib/classes/SessionDecoder.class.php b/lib/classes/SessionDecoder.class.php
index 8c0bc6b..d437494 100644
--- a/lib/classes/SessionDecoder.class.php
+++ b/lib/classes/SessionDecoder.class.php
@@ -83,69 +83,42 @@ class SessionDecoder implements ArrayAccess, Countable, Iterator {
return $this->var_names;
}
- /**
- * @todo Add void return type when Stud.IP requires PHP8 minimal
- */
- #[ReturnTypeWillChange]
- public function rewind()
+ public function rewind(): void
{
reset($this->var_names);
}
- /**
- * @todo Add mixed return type when Stud.IP requires PHP8 minimal
- */
- #[ReturnTypeWillChange]
- public function current()
+ public function current(): mixed
{
$current = current($this->var_names);
return $current !== false ? $this->offsetGet($current) : false;
}
- /**
- * @todo Add mixed return type when Stud.IP requires PHP8 minimal
- */
- #[ReturnTypeWillChange]
- public function key()
+ public function key(): mixed
{
return current($this->var_names);
}
- /**
- * @todo Add void return type when Stud.IP requires PHP8 minimal
- */
- #[ReturnTypeWillChange]
- public function next()
+ public function next(): void
{
next($this->var_names);
}
- /**
- * @todo Add bool return type when Stud.IP requires PHP8 minimal
- */
- #[ReturnTypeWillChange]
- public function valid()
+ public function valid(): bool
{
$current = current($this->var_names);
return $current !== false;
}
- /**
- * @todo Add bool return type when Stud.IP requires PHP8 minimal
- */
- #[ReturnTypeWillChange]
- public function offsetExists($offset)
+ public function offsetExists($offset): bool
{
return isset($this->encoded_session[$offset]);
}
/**
- * @param $offset
- * @return mixed|null
- * @todo Add mixed return type when Stud.IP requires PHP8 minimal
+ * @param string $offset
*/
- #[ReturnTypeWillChange]
- public function offsetGet($offset)
+ public function offsetGet($offset): mixed
{
if($this->offsetExists($offset) && !isset($this->decoded_session[$offset])) {
$this->decoded_session[$offset] = unserialize($this->encoded_session[$offset]);
@@ -153,27 +126,15 @@ class SessionDecoder implements ArrayAccess, Countable, Iterator {
return $this->decoded_session[$offset] ?? null;
}
- /**
- * @todo Add void return type when Stud.IP requires PHP8 minimal
- */
- #[ReturnTypeWillChange]
- public function offsetSet($offset, $value)
+ public function offsetSet($offset, $value): void
{
}
- /**
- * @todo Add void return type when Stud.IP requires PHP8 minimal
- */
- #[ReturnTypeWillChange]
- public function offsetUnset($offset)
+ public function offsetUnset($offset): void
{
}
- /**
- * @todo Add int return type when Stud.IP requires PHP8 minimal
- */
- #[ReturnTypeWillChange]
- public function count()
+ public function count(): int
{
return count($this->var_names);
}
diff --git a/lib/classes/StudipArrayObject.class.php b/lib/classes/StudipArrayObject.class.php
index fe9aad1..531da67 100644
--- a/lib/classes/StudipArrayObject.class.php
+++ b/lib/classes/StudipArrayObject.class.php
@@ -157,13 +157,8 @@ 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()
+ public function count(): int
{
return count($this->storage);
}
@@ -216,13 +211,8 @@ 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()
+ public function getIterator(): Traversable
{
$class = $this->iteratorClass;
@@ -273,12 +263,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
* Returns whether the requested key exists
*
* @param mixed $key
- * @return bool
- *
- * @todo Add void return type when Stud.IP requires PHP8 minimal
*/
- #[ReturnTypeWillChange]
- public function offsetExists($key)
+ public function offsetExists($key): bool
{
return isset($this->storage[$key]);
}
@@ -287,12 +273,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
* Returns the value at the specified key
*
* @param mixed $key
- * @return mixed
- *
- * @todo Add mixed return type when Stud.IP requires PHP8 minimal
*/
- #[ReturnTypeWillChange]
- public function offsetGet($key)
+ public function offsetGet($key): mixed
{
$ret = null;
if (!$this->offsetExists($key)) {
@@ -308,12 +290,8 @@ 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)
+ public function offsetSet($key, $value): void
{
if (is_null($key)) {
$this->append($value);
@@ -326,12 +304,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
* Unsets the value at the specified key
*
* @param mixed $key
- * @return void
- *
- * @todo Add void return type when Stud.IP requires PHP8 minimal
*/
- #[ReturnTypeWillChange]
- public function offsetUnset($key)
+ public function offsetUnset($key): void
{
if ($this->offsetExists($key)) {
unset($this->storage[$key]);
diff --git a/lib/classes/StudipCachedArray.php b/lib/classes/StudipCachedArray.php
index 18bb55b..1232d00 100644
--- a/lib/classes/StudipCachedArray.php
+++ b/lib/classes/StudipCachedArray.php
@@ -71,13 +71,8 @@ class StudipCachedArray implements ArrayAccess
* Returns the value at given offset or null if it doesn't exist.
*
* @param string $offset Offset
- *
- * @return mixed
- *
- * @todo Add mixed return type when Stud.IP requires PHP8 minimal
*/
- #[ReturnTypeWillChange]
- public function offsetGet($offset)
+ public function offsetGet($offset): mixed
{
$this->loadData($offset);
return $this->data[$offset];
diff --git a/lib/classes/StudipPDO.class.php b/lib/classes/StudipPDO.class.php
index e77a37f..8fa3418 100644
--- a/lib/classes/StudipPDO.class.php
+++ b/lib/classes/StudipPDO.class.php
@@ -122,23 +122,20 @@ class StudipPDO extends PDO
* Quotes the given value in a form appropriate for the type.
* If no explicit type is given, the value's PHP type is used.
*
- * @param mixed $value PHP value to quote
+ * @param mixed $string PHP value to quote
* @param ?int $type parameter type (e.g. PDO::PARAM_STR)
* @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)
+ public function quote($string, $type = null): false|string
{
if (!isset($type)) {
- if (is_null($value)) {
+ if (is_null($string)) {
$type = PDO::PARAM_NULL;
- } else if (is_bool($value)) {
+ } else if (is_bool($string)) {
$type = PDO::PARAM_BOOL;
- } else if (is_int($value)) {
+ } else if (is_int($string)) {
$type = PDO::PARAM_INT;
- } else if (is_array($value)) {
+ } else if (is_array($string)) {
$type = StudipPDO::PARAM_ARRAY;
} else {
$type = PDO::PARAM_STR;
@@ -149,28 +146,24 @@ class StudipPDO extends PDO
case PDO::PARAM_NULL:
return 'NULL';
case PDO::PARAM_BOOL:
- return $value ? '1' : '0';
+ return $string ? '1' : '0';
case PDO::PARAM_INT:
- return (int) $value;
+ return (int) $string;
case StudipPDO::PARAM_ARRAY:
- return is_array($value) && count($value) ? join(',', array_map([$this, 'quote'], $value)) : 'NULL';
+ return is_array($string) && count($string) ? join(',', array_map([$this, 'quote'], $string)) : 'NULL';
case StudipPDO::PARAM_COLUMN:
- return preg_replace('/\\W/', '', $value);
+ return preg_replace('/\\W/', '', $string);
default:
- return parent::quote($value);
+ return parent::quote($string);
}
}
/**
* Executes an SQL statement and returns the number of affected rows.
*
- * @param string SQL statement
- * @return int|false number of affected rows
- *
- * @todo Add mixed return type when Stud.IP requires PHP8 minimal
+ * @param string $statement SQL statement
*/
- #[ReturnTypeWillChange]
- public function exec($statement)
+ public function exec(string $statement): false|int
{
$this->verify($statement);
return parent::exec($statement);
diff --git a/lib/classes/StudipPDOStatement.php b/lib/classes/StudipPDOStatement.php
index 4a3d069..80a8dc8 100644
--- a/lib/classes/StudipPDOStatement.php
+++ b/lib/classes/StudipPDOStatement.php
@@ -99,11 +99,8 @@ 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()
+ public function getIterator(): Traversable
{
return $this->stmt;
}
diff --git a/lib/classes/UserDataAdapter.php b/lib/classes/UserDataAdapter.php
index 0a0c3be..5277145 100644
--- a/lib/classes/UserDataAdapter.php
+++ b/lib/classes/UserDataAdapter.php
@@ -26,66 +26,48 @@ 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)
+ public function offsetExists($offset): bool
{
return $this->user->offsetExists($this->adaptOffset($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)
+ public function offsetGet($offset): mixed
{
return $this->user->offsetGet($this->adaptOffset($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)
+ public function offsetSet($offset, $value): void
{
$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)
+ public function offsetUnset($offset): void
{
$this->user->offsetUnset($this->adaptOffset($offset));
}
/**
* @see Countable::count()
- *
- * @todo Add int return type when Stud.IP requires PHP8 minimal
*/
- #[ReturnTypeWillChange]
- public function count()
+ public function count(): int
{
return $this->user->count();
}
/**
* @see IteratorAggregate::getIterator()
- *
- * @todo Add Traversable return type when Stud.IP requires PHP8 minimal
*/
- #[ReturnTypeWillChange]
- public function getIterator()
+ public function getIterator(): Traversable
{
return $this->user->getIterator();
}
diff --git a/lib/classes/restapi/Response.php b/lib/classes/restapi/Response.php
index 4417979..56d9b65 100644
--- a/lib/classes/restapi/Response.php
+++ b/lib/classes/restapi/Response.php
@@ -123,41 +123,25 @@ 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)
+ public function offsetExists($offset): bool
{
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)
+ public function offsetGet($offset): mixed
{
return @$this->headers[$offset];
}
- /**
- * @todo Add void return type when Stud.IP requires PHP8 minimal
- */
- #[ReturnTypeWillChange]
- public function offsetSet($offset, $value)
+ public function offsetSet($offset, $value): void
{
$this->headers[$offset] = $value;
}
- /**
- * @todo Add void return type when Stud.IP requires PHP8 minimal
- */
- #[ReturnTypeWillChange]
- public function offsetUnset($offset)
+ public function offsetUnset($offset): void
{
unset($this->headers[$offset]);
}
diff --git a/lib/classes/sidebar/AttributesArrayAccessTrait.php b/lib/classes/sidebar/AttributesArrayAccessTrait.php
index 7bea834..09fc030 100644
--- a/lib/classes/sidebar/AttributesArrayAccessTrait.php
+++ b/lib/classes/sidebar/AttributesArrayAccessTrait.php
@@ -3,41 +3,25 @@ trait AttributesArrayAccessTrait
{
public $attributes = [];
- /**
- * @todo Add bool return type when Stud.IP requires PHP8 minimal
- */
- #[ReturnTypeWillChange]
- public function offsetExists($offset)
+ public function offsetExists($offset): bool
{
return isset($this->attributes[$offset]);
}
/**
- * @param $offset
- * @return mixed
- *
- * @todo Add mixed return type when Stud.IP requires PHP8 minimal
+ * @param string $offset
*/
- #[ReturnTypeWillChange]
- public function offsetGet($offset)
+ public function offsetGet($offset): mixed
{
return $this->attributes[$offset];
}
- /**
- * @todo Add void return type when Stud.IP requires PHP8 minimal
- */
- #[ReturnTypeWillChange]
- public function offsetSet($offset, $value)
+ public function offsetSet($offset, $value): void
{
$this->attributes[$offset] = $value;
}
- /**
- * @todo Add void return type when Stud.IP requires PHP8 minimal
- */
- #[ReturnTypeWillChange]
- public function offsetUnset($offset)
+ public function offsetUnset($offset): void
{
unset($this->attributes[$offset]);
}
diff --git a/lib/filesystem/StandardFile.php b/lib/filesystem/StandardFile.php
index e051871..9d2d35c 100644
--- a/lib/filesystem/StandardFile.php
+++ b/lib/filesystem/StandardFile.php
@@ -112,46 +112,33 @@ 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)
+ public function offsetExists($offset): bool
{
return $this->__isset($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)
+ public function offsetGet($offset): mixed
{
return $this->__get($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)
+ public function offsetSet($offset, $value): void
{
$this->__set($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)
+ public function offsetUnset($offset): void
{
-
}
/**
diff --git a/lib/filesystem/UnknownFileType.php b/lib/filesystem/UnknownFileType.php
index bfd00ba..33d6c53 100644
--- a/lib/filesystem/UnknownFileType.php
+++ b/lib/filesystem/UnknownFileType.php
@@ -51,46 +51,33 @@ 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)
+ public function offsetExists($offset): bool
{
return $this->__isset($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)
+ public function offsetGet($offset): mixed
{
return $this->__get($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)
+ public function offsetSet($offset, $value): void
{
$this->__set($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)
+ public function offsetUnset($offset): void
{
-
}
/**
* @inheritDoc
diff --git a/lib/models/DataField.class.php b/lib/models/DataField.class.php
index 2d745a9..8a0bdb6 100644
--- a/lib/models/DataField.class.php
+++ b/lib/models/DataField.class.php
@@ -256,11 +256,8 @@ 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()
+ public function count(): int
{
return DatafieldEntryModel::countBySQL('datafield_id = ?', [$this->id]);
}
diff --git a/lib/models/SimpleCollection.class.php b/lib/models/SimpleCollection.class.php
index 4d77682..6acc10d 100644
--- a/lib/models/SimpleCollection.class.php
+++ b/lib/models/SimpleCollection.class.php
@@ -299,12 +299,9 @@ class SimpleCollection extends StudipArrayObject
* @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)
+
+ public function offsetSet($index, $newval): void
{
if (is_numeric($index)) {
$index = (int) $index;
@@ -318,11 +315,8 @@ 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)
+ public function offsetUnset($index): void
{
if ($this->offsetExists($index)) {
$this->deleted[] = $this->offsetGet($index);
diff --git a/lib/models/SimpleORMap.class.php b/lib/models/SimpleORMap.class.php
index 2013db4..f86ec6f 100644
--- a/lib/models/SimpleORMap.class.php
+++ b/lib/models/SimpleORMap.class.php
@@ -1638,16 +1638,13 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
return false;
}
}
+
/**
* ArrayAccess: Check whether the given offset exists.
*
* @param string $offset
- * @return bool
- *
- * @todo Add bool return type when Stud.IP requires PHP8 minimal
*/
- #[ReturnTypeWillChange]
- public function offsetExists($offset)
+ public function offsetExists($offset): bool
{
return $this->__isset($offset);
}
@@ -1659,11 +1656,8 @@ 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)
+ public function offsetGet($offset): mixed
{
return $this->getValue($offset);
}
@@ -1675,49 +1669,34 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
* @throws BadMethodCallException if setter for additional field could not be found
* @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)
+ public function offsetSet($offset, $value): void
{
$this->setValue($offset, $value);
}
+
/**
* ArrayAccess: unset the value at the given offset (not applicable)
*
* @param string $offset
- * @return void
- *
- * @todo Add void return type when Stud.IP requires PHP8 minimal
*/
- #[ReturnTypeWillChange]
- public function offsetUnset($offset)
+ public function offsetUnset($offset): void
{
}
+
/**
* IteratorAggregate
- *
- * @return ArrayIterator
- *
- * @todo Add Traversable return type when Stud.IP requires PHP8 minimal
*/
- #[ReturnTypeWillChange]
- public function getIterator()
+ public function getIterator(): ArrayIterator
{
return new ArrayIterator($this->toArray());
}
+
/**
* Countable
- *
- * @return int
- *
- * @todo Add int return type when Stud.IP requires PHP8 minimal
*/
- #[ReturnTypeWillChange]
- public function count()
+ public function count(): int
{
return count($this->known_slots()) - count($this->relations);
}
diff --git a/lib/models/SimpleORMapCollection.class.php b/lib/models/SimpleORMapCollection.class.php
index f06ee17..7debb80 100644
--- a/lib/models/SimpleORMapCollection.class.php
+++ b/lib/models/SimpleORMapCollection.class.php
@@ -92,11 +92,8 @@ 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)
+ public function offsetSet($index, $newval): void
{
if (!is_null($index)) {
$index = (int)$index;
diff --git a/lib/navigation/Navigation.php b/lib/navigation/Navigation.php
index 3c02e86..af4355b 100644
--- a/lib/navigation/Navigation.php
+++ b/lib/navigation/Navigation.php
@@ -562,12 +562,9 @@ class Navigation implements IteratorAggregate
}
/**
- * IteratorAggregate: Create interator for request parameters.
- *
- * @todo Add Traversable return type when Stud.IP requires PHP8 minimal
+ * IteratorAggregate: Create iterator for request parameters.
*/
- #[\ReturnTypeWillChange]
- public function getIterator()
+ public function getIterator(): Traversable
{
return new ArrayIterator($this->getSubNavigation());
}