Skip to content
Snippets Groups Projects
Commit c659d71e authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by David Siegfried
Browse files

adjustments for php8, fixes #4111

Closes #4111

Merge request studip/studip!2956
parent f8d42374
Branches
Tags
2 merge requests!4241Draft: Resolve "Im fromSORM fehlt Eingabename des `templates/forms/wysiwyg_input.php`",!2956adjustments for php8, fixes #4111
Pipeline #23098 passed
Showing
with 97 additions and 367 deletions
...@@ -79,66 +79,48 @@ class Stream implements \ArrayAccess, \Countable, \IteratorAggregate ...@@ -79,66 +79,48 @@ class Stream implements \ArrayAccess, \Countable, \IteratorAggregate
/** /**
* ArrayAccess: Check whether the given offset exists. * ArrayAccess: Check whether the given offset exists.
*
* @todo Add bool return type when Stud.IP requires PHP8 minimal
*/ */
#[\ReturnTypeWillChange] public function offsetExists($offset): bool
public function offsetExists($offset)
{ {
return isset($this->activities[$offset]); return isset($this->activities[$offset]);
} }
/** /**
* ArrayAccess: Get the value at the given 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): mixed
public function offsetGet($offset)
{ {
return $this->activities[$offset]; return $this->activities[$offset];
} }
/** /**
* ArrayAccess: Set the value at the given 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): void
public function offsetSet($offset, $value)
{ {
$this->activities[$offset] = $value; $this->activities[$offset] = $value;
} }
/** /**
* ArrayAccess: unset the value at the given offset (not applicable) * 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): void
public function offsetUnset($offset)
{ {
unset($this->activities[$offset]); unset($this->activities[$offset]);
} }
/** /**
* IteratorAggregate * IteratorAggregate
*
* @todo Add \Traversable return type when Stud.IP requires PHP8 minimal
*/ */
#[\ReturnTypeWillChange] public function getIterator(): \Traversable
public function getIterator()
{ {
return new \ArrayIterator($this->activities); return new \ArrayIterator($this->activities);
} }
/** /**
* Countable * Countable
*
* @todo Add int return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function count(): int
public function count()
{ {
return count($this->activities); return count($this->activities);
} }
......
...@@ -153,11 +153,8 @@ class Config implements ArrayAccess, Countable, IteratorAggregate ...@@ -153,11 +153,8 @@ class Config implements ArrayAccess, Countable, IteratorAggregate
/** /**
* IteratorAggregate * IteratorAggregate
*
* @todo Add Traversable return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function getIterator(): Traversable
public function getIterator()
{ {
return new ArrayIterator($this->data); return new ArrayIterator($this->data);
} }
...@@ -188,55 +185,40 @@ class Config implements ArrayAccess, Countable, IteratorAggregate ...@@ -188,55 +185,40 @@ class Config implements ArrayAccess, Countable, IteratorAggregate
/** /**
* ArrayAccess: Check whether the given offset exists. * ArrayAccess: Check whether the given offset exists.
*
* @todo Add bool return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetExists($offset): bool
public function offsetExists($offset)
{ {
return isset($this->$offset); return isset($this->$offset);
} }
/** /**
* ArrayAccess: Get the value at the given 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): mixed
public function offsetGet($offset)
{ {
return $this->$offset; return $this->$offset;
} }
/** /**
* ArrayAccess: Set the value at the given 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): void
public function offsetSet($offset, $value)
{ {
$this->$offset = $value; $this->$offset = $value;
} }
/** /**
* ArrayAccess: unset the value at the given offset (not applicable) * 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): void
public function offsetUnset($offset)
{ {
} }
/** /**
* Countable * Countable
*
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function count(): int
public function count()
{ {
return count($this->data); return count($this->data);
} }
......
...@@ -92,19 +92,15 @@ class ForumHelpers { ...@@ -92,19 +92,15 @@ class ForumHelpers {
*/ */
public static function translate_perm($perm) public static function translate_perm($perm)
{ {
$mapping = [ return match ($perm) {
'root' => _('Root'), 'root' => _('Root'),
'admin' => _('Administrator/-in'), 'admin' => _('Administrator/-in'),
'dozent' => _('Lehrende/-r'), 'dozent' => _('Lehrende/-r'),
'tutor' => _('Tutor/-in'), 'tutor' => _('Tutor/-in'),
'autor' => _('Autor/-in'), 'autor' => _('Autor/-in'),
'user' => _('Leser/-in'), 'user' => _('Leser/-in'),
]; default => '',
};
// TODO: Activate next when devboard reliably runs on PHP7
// return $mapping[$perm] ?? '';
return isset($mapping[$perm]) ? $mapping[$perm] : '';
} }
/** /**
......
...@@ -78,13 +78,8 @@ class I18NString implements JsonSerializable ...@@ -78,13 +78,8 @@ class I18NString implements JsonSerializable
/** /**
* Return the JSON representation of this i18n field in selected language. * 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(): string
public function jsonSerialize()
{ {
return (string) $this; return (string) $this;
} }
......
...@@ -18,53 +18,38 @@ class DummyNavigation extends \Navigation implements \ArrayAccess ...@@ -18,53 +18,38 @@ class DummyNavigation extends \Navigation implements \ArrayAccess
/** /**
* ArrayAccess: Check whether the given offset exists. * ArrayAccess: Check whether the given offset exists.
*
* @todo Add bool return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetExists($offset): bool
public function offsetExists($offset)
{ {
return true; return true;
} }
/** /**
* ArrayAccess: Get the value at the given 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): mixed
public function offsetGet($offset)
{ {
return $this; return $this;
} }
/** /**
* ArrayAccess: Set the value at the given 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): void
public function offsetSet($offset, $value)
{ {
} }
/** /**
* ArrayAccess: Delete the value at the given offset. * ArrayAccess: Delete the value at the given offset.
*
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/ */
#[\ReturnTypeWillChange] public function offsetUnset($offset): void
public function offsetUnset($offset)
{ {
} }
/** /**
* IteratorAggregate: Create interator for request parameters. * IteratorAggregate: Create iterator for request parameters.
*
* @todo Add \Traversable return type when Stud.IP requires PHP8 minimal
*/ */
#[\ReturnTypeWillChange] public function getIterator(): \Traversable
public function getIterator()
{ {
return new \ArrayIterator(); return new \ArrayIterator();
} }
......
...@@ -78,13 +78,8 @@ class MultiDimArrayObject extends StudipArrayObject ...@@ -78,13 +78,8 @@ class MultiDimArrayObject extends StudipArrayObject
/** /**
* Create a new iterator from an ArrayObject instance * 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(): Traversable
public function getIterator()
{ {
$class = $this->iteratorClass; $class = $this->iteratorClass;
...@@ -96,12 +91,8 @@ class MultiDimArrayObject extends StudipArrayObject ...@@ -96,12 +91,8 @@ class MultiDimArrayObject extends StudipArrayObject
* *
* @param mixed $key * @param mixed $key
* @param mixed $value * @param mixed $value
* @return void
*
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetSet($key, $value): void
public function offsetSet($key, $value)
{ {
$new_value = $this->recursiveArrayToArrayObjects($value); $new_value = $this->recursiveArrayToArrayObjects($value);
if (is_array($new_value)) { if (is_array($new_value)) {
......
...@@ -45,55 +45,40 @@ class Request implements ArrayAccess, IteratorAggregate ...@@ -45,55 +45,40 @@ class Request implements ArrayAccess, IteratorAggregate
/** /**
* ArrayAccess: Check whether the given offset exists. * ArrayAccess: Check whether the given offset exists.
*
* @todo Add bool return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetExists($offset): bool
public function offsetExists($offset)
{ {
return isset($this->params[$offset]); return isset($this->params[$offset]);
} }
/** /**
* ArrayAccess: Get the value at the given 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): mixed
public function offsetGet($offset)
{ {
return $this->params[$offset] ?? null; return $this->params[$offset] ?? null;
} }
/** /**
* ArrayAccess: Set the value at the given 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): void
public function offsetSet($offset, $value)
{ {
$this->params[$offset] = $value; $this->params[$offset] = $value;
} }
/** /**
* ArrayAccess: Delete the value at the given offset. * ArrayAccess: Delete the value at the given offset.
*
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetUnset($offset): void
public function offsetUnset($offset)
{ {
unset($this->params[$offset]); unset($this->params[$offset]);
} }
/** /**
* IteratorAggregate: Create interator for request parameters. * IteratorAggregate: Create iterator for request parameters.
*
* @todo Add Traversable return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function getIterator(): Traversable
public function getIterator()
{ {
return new ArrayIterator((array)$this->params); return new ArrayIterator((array)$this->params);
} }
......
...@@ -478,11 +478,8 @@ class SemClass implements ArrayAccess ...@@ -478,11 +478,8 @@ class SemClass implements ArrayAccess
* deprecated, does nothing, should not be used * deprecated, does nothing, should not be used
* @param string $offset * @param string $offset
* @param mixed $value * @param mixed $value
*
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetSet($offset, $value): void
public function offsetSet($offset, $value)
{ {
} }
...@@ -490,12 +487,8 @@ class SemClass implements ArrayAccess ...@@ -490,12 +487,8 @@ class SemClass implements ArrayAccess
* Compatibility function with old $SEM_CLASS variable for plugins. Maps the * Compatibility function with old $SEM_CLASS variable for plugins. Maps the
* new array-structure to the old boolean values. * new array-structure to the old boolean values.
* @param integer $offset: name of attribute * @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): mixed
public function offsetGet($offset)
{ {
switch ($offset) { switch ($offset) {
case "name": case "name":
...@@ -528,12 +521,8 @@ class SemClass implements ArrayAccess ...@@ -528,12 +521,8 @@ class SemClass implements ArrayAccess
/** /**
* ArrayAccess method to check if an attribute exists. * ArrayAccess method to check if an attribute exists.
* @param int $offset * @param int $offset
* @return bool
*
* @todo Add bool return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetExists($offset): bool
public function offsetExists($offset)
{ {
return isset($this->data[$offset]); return isset($this->data[$offset]);
} }
...@@ -541,11 +530,8 @@ class SemClass implements ArrayAccess ...@@ -541,11 +530,8 @@ class SemClass implements ArrayAccess
/** /**
* deprecated, does nothing, should not be used * deprecated, does nothing, should not be used
* @param string $offset * @param string $offset
*
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetUnset($offset): void
public function offsetUnset($offset)
{ {
} }
......
...@@ -119,11 +119,9 @@ class SemType implements ArrayAccess ...@@ -119,11 +119,9 @@ class SemType implements ArrayAccess
* deprecated, does nothing, should not be used * deprecated, does nothing, should not be used
* @param string $offset * @param string $offset
* @param mixed $value * @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 ...@@ -131,12 +129,8 @@ class SemType implements ArrayAccess
* Compatibility function with old $SEM_TYPE variable for plugins. Maps the * Compatibility function with old $SEM_TYPE variable for plugins. Maps the
* new array-structure to the old boolean values. * new array-structure to the old boolean values.
* @param integer $offset: name of attribute * @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): mixed
public function offsetGet($offset)
{ {
switch ($offset) { switch ($offset) {
case "name": case "name":
...@@ -153,12 +147,8 @@ class SemType implements ArrayAccess ...@@ -153,12 +147,8 @@ class SemType implements ArrayAccess
/** /**
* ArrayAccess method to check if an attribute exists. * ArrayAccess method to check if an attribute exists.
* @param mixed $offset * @param mixed $offset
* @return bool
*
* @todo Add bool return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetExists($offset): bool
public function offsetExists($offset)
{ {
return isset($this->data[$offset]); return isset($this->data[$offset]);
} }
...@@ -166,11 +156,8 @@ class SemType implements ArrayAccess ...@@ -166,11 +156,8 @@ class SemType implements ArrayAccess
/** /**
* deprecated, does nothing, should not be used * deprecated, does nothing, should not be used
* @param string $offset * @param string $offset
*
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetUnset($offset): void
public function offsetUnset($offset)
{ {
} }
......
...@@ -83,69 +83,42 @@ class SessionDecoder implements ArrayAccess, Countable, Iterator { ...@@ -83,69 +83,42 @@ class SessionDecoder implements ArrayAccess, Countable, Iterator {
return $this->var_names; return $this->var_names;
} }
/** public function rewind(): void
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/
#[ReturnTypeWillChange]
public function rewind()
{ {
reset($this->var_names); reset($this->var_names);
} }
/** public function current(): mixed
* @todo Add mixed return type when Stud.IP requires PHP8 minimal
*/
#[ReturnTypeWillChange]
public function current()
{ {
$current = current($this->var_names); $current = current($this->var_names);
return $current !== false ? $this->offsetGet($current) : false; return $current !== false ? $this->offsetGet($current) : false;
} }
/** public function key(): mixed
* @todo Add mixed return type when Stud.IP requires PHP8 minimal
*/
#[ReturnTypeWillChange]
public function key()
{ {
return current($this->var_names); return current($this->var_names);
} }
/** public function next(): void
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/
#[ReturnTypeWillChange]
public function next()
{ {
next($this->var_names); next($this->var_names);
} }
/** public function valid(): bool
* @todo Add bool return type when Stud.IP requires PHP8 minimal
*/
#[ReturnTypeWillChange]
public function valid()
{ {
$current = current($this->var_names); $current = current($this->var_names);
return $current !== false; return $current !== false;
} }
/** public function offsetExists($offset): bool
* @todo Add bool return type when Stud.IP requires PHP8 minimal
*/
#[ReturnTypeWillChange]
public function offsetExists($offset)
{ {
return isset($this->encoded_session[$offset]); return isset($this->encoded_session[$offset]);
} }
/** /**
* @param $offset * @param string $offset
* @return mixed|null
* @todo Add mixed return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetGet($offset): mixed
public function offsetGet($offset)
{ {
if($this->offsetExists($offset) && !isset($this->decoded_session[$offset])) { if($this->offsetExists($offset) && !isset($this->decoded_session[$offset])) {
$this->decoded_session[$offset] = unserialize($this->encoded_session[$offset]); $this->decoded_session[$offset] = unserialize($this->encoded_session[$offset]);
...@@ -153,27 +126,15 @@ class SessionDecoder implements ArrayAccess, Countable, Iterator { ...@@ -153,27 +126,15 @@ class SessionDecoder implements ArrayAccess, Countable, Iterator {
return $this->decoded_session[$offset] ?? null; return $this->decoded_session[$offset] ?? null;
} }
/** public function offsetSet($offset, $value): void
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/
#[ReturnTypeWillChange]
public function offsetSet($offset, $value)
{ {
} }
/** public function offsetUnset($offset): void
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/
#[ReturnTypeWillChange]
public function offsetUnset($offset)
{ {
} }
/** public function count(): int
* @todo Add int return type when Stud.IP requires PHP8 minimal
*/
#[ReturnTypeWillChange]
public function count()
{ {
return count($this->var_names); return count($this->var_names);
} }
......
...@@ -157,13 +157,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable, ...@@ -157,13 +157,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
/** /**
* Get the number of public properties in the ArrayObject * 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(): int
public function count()
{ {
return count($this->storage); return count($this->storage);
} }
...@@ -216,13 +211,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable, ...@@ -216,13 +211,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
/** /**
* Create a new iterator from an ArrayObject instance * 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(): Traversable
public function getIterator()
{ {
$class = $this->iteratorClass; $class = $this->iteratorClass;
...@@ -273,12 +263,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable, ...@@ -273,12 +263,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
* Returns whether the requested key exists * Returns whether the requested key exists
* *
* @param mixed $key * @param mixed $key
* @return bool
*
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetExists($key): bool
public function offsetExists($key)
{ {
return isset($this->storage[$key]); return isset($this->storage[$key]);
} }
...@@ -287,12 +273,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable, ...@@ -287,12 +273,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
* Returns the value at the specified key * Returns the value at the specified key
* *
* @param mixed $key * @param mixed $key
* @return mixed
*
* @todo Add mixed return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetGet($key): mixed
public function offsetGet($key)
{ {
$ret = null; $ret = null;
if (!$this->offsetExists($key)) { if (!$this->offsetExists($key)) {
...@@ -308,12 +290,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable, ...@@ -308,12 +290,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
* *
* @param mixed $key * @param mixed $key
* @param mixed $value * @param mixed $value
* @return void
*
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetSet($key, $value): void
public function offsetSet($key, $value)
{ {
if (is_null($key)) { if (is_null($key)) {
$this->append($value); $this->append($value);
...@@ -326,12 +304,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable, ...@@ -326,12 +304,8 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
* Unsets the value at the specified key * Unsets the value at the specified key
* *
* @param mixed $key * @param mixed $key
* @return void
*
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetUnset($key): void
public function offsetUnset($key)
{ {
if ($this->offsetExists($key)) { if ($this->offsetExists($key)) {
unset($this->storage[$key]); unset($this->storage[$key]);
......
...@@ -71,13 +71,8 @@ class StudipCachedArray implements ArrayAccess ...@@ -71,13 +71,8 @@ class StudipCachedArray implements ArrayAccess
* Returns the value at given offset or null if it doesn't exist. * Returns the value at given offset or null if it doesn't exist.
* *
* @param string $offset Offset * @param string $offset Offset
*
* @return mixed
*
* @todo Add mixed return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetGet($offset): mixed
public function offsetGet($offset)
{ {
$this->loadData($offset); $this->loadData($offset);
return $this->data[$offset]; return $this->data[$offset];
......
...@@ -122,23 +122,20 @@ class StudipPDO extends PDO ...@@ -122,23 +122,20 @@ class StudipPDO extends PDO
* Quotes the given value in a form appropriate for the type. * Quotes the given value in a form appropriate for the type.
* If no explicit type is given, the value's PHP type is used. * 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) * @param ?int $type parameter type (e.g. PDO::PARAM_STR)
* @return string|false 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($string, $type = null): false|string
public function quote($value, $type = null)
{ {
if (!isset($type)) { if (!isset($type)) {
if (is_null($value)) { if (is_null($string)) {
$type = PDO::PARAM_NULL; $type = PDO::PARAM_NULL;
} else if (is_bool($value)) { } else if (is_bool($string)) {
$type = PDO::PARAM_BOOL; $type = PDO::PARAM_BOOL;
} else if (is_int($value)) { } else if (is_int($string)) {
$type = PDO::PARAM_INT; $type = PDO::PARAM_INT;
} else if (is_array($value)) { } else if (is_array($string)) {
$type = StudipPDO::PARAM_ARRAY; $type = StudipPDO::PARAM_ARRAY;
} else { } else {
$type = PDO::PARAM_STR; $type = PDO::PARAM_STR;
...@@ -149,28 +146,24 @@ class StudipPDO extends PDO ...@@ -149,28 +146,24 @@ class StudipPDO extends PDO
case PDO::PARAM_NULL: case PDO::PARAM_NULL:
return 'NULL'; return 'NULL';
case PDO::PARAM_BOOL: case PDO::PARAM_BOOL:
return $value ? '1' : '0'; return $string ? '1' : '0';
case PDO::PARAM_INT: case PDO::PARAM_INT:
return (int) $value; return (int) $string;
case StudipPDO::PARAM_ARRAY: 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: case StudipPDO::PARAM_COLUMN:
return preg_replace('/\\W/', '', $value); return preg_replace('/\\W/', '', $string);
default: default:
return parent::quote($value); return parent::quote($string);
} }
} }
/** /**
* Executes an SQL statement and returns the number of affected rows. * Executes an SQL statement and returns the number of affected rows.
* *
* @param string SQL statement * @param string $statement SQL statement
* @return int|false number of affected rows
*
* @todo Add mixed return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function exec(string $statement): false|int
public function exec($statement)
{ {
$this->verify($statement); $this->verify($statement);
return parent::exec($statement); return parent::exec($statement);
......
...@@ -99,11 +99,8 @@ class StudipPDOStatement implements IteratorAggregate ...@@ -99,11 +99,8 @@ class StudipPDOStatement implements IteratorAggregate
/** /**
* Forwards all Iterator methods to the actual statement object. * Forwards all Iterator methods to the actual statement object.
*
* @todo Add Traversable return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function getIterator(): Traversable
public function getIterator()
{ {
return $this->stmt; return $this->stmt;
} }
......
...@@ -26,66 +26,48 @@ class UserDataAdapter implements ArrayAccess, Countable, IteratorAggregate ...@@ -26,66 +26,48 @@ class UserDataAdapter implements ArrayAccess, Countable, IteratorAggregate
/** /**
* ArrayAccess: Check whether the given offset exists. * ArrayAccess: Check whether the given offset exists.
*
* @todo Add bool return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetExists($offset): bool
public function offsetExists($offset)
{ {
return $this->user->offsetExists($this->adaptOffset($offset)); return $this->user->offsetExists($this->adaptOffset($offset));
} }
/** /**
* ArrayAccess: Get the value at the given 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): mixed
public function offsetGet($offset)
{ {
return $this->user->offsetGet($this->adaptOffset($offset)); return $this->user->offsetGet($this->adaptOffset($offset));
} }
/** /**
* ArrayAccess: Set the value at the given 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): void
public function offsetSet($offset, $value)
{ {
$this->user->offsetSet($this->adaptOffset($offset), $value); $this->user->offsetSet($this->adaptOffset($offset), $value);
} }
/** /**
* ArrayAccess: unset the value at the given offset. * ArrayAccess: unset the value at the given offset.
*
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetUnset($offset): void
public function offsetUnset($offset)
{ {
$this->user->offsetUnset($this->adaptOffset($offset)); $this->user->offsetUnset($this->adaptOffset($offset));
} }
/** /**
* @see Countable::count() * @see Countable::count()
*
* @todo Add int return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function count(): int
public function count()
{ {
return $this->user->count(); return $this->user->count();
} }
/** /**
* @see IteratorAggregate::getIterator() * @see IteratorAggregate::getIterator()
*
* @todo Add Traversable return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function getIterator(): Traversable
public function getIterator()
{ {
return $this->user->getIterator(); return $this->user->getIterator();
} }
......
...@@ -123,41 +123,25 @@ class Response implements \ArrayAccess ...@@ -123,41 +123,25 @@ class Response implements \ArrayAccess
// array access methods for headers // array access methods for headers
/** public function offsetExists($offset): bool
* @todo Add bool return type when Stud.IP requires PHP8 minimal
*/
#[ReturnTypeWillChange]
public function offsetExists($offset)
{ {
return isset($this->headers[$offset]); return isset($this->headers[$offset]);
} }
/** /**
* @param $offset * @param $offset
* @return mixed
*
* @todo Add mixed return type when Stud.IP requires PHP8 minimal
*/ */
#[\ReturnTypeWillChange] public function offsetGet($offset): mixed
public function offsetGet($offset)
{ {
return @$this->headers[$offset]; return @$this->headers[$offset];
} }
/** public function offsetSet($offset, $value): void
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/
#[ReturnTypeWillChange]
public function offsetSet($offset, $value)
{ {
$this->headers[$offset] = $value; $this->headers[$offset] = $value;
} }
/** public function offsetUnset($offset): void
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/
#[ReturnTypeWillChange]
public function offsetUnset($offset)
{ {
unset($this->headers[$offset]); unset($this->headers[$offset]);
} }
......
...@@ -3,41 +3,25 @@ trait AttributesArrayAccessTrait ...@@ -3,41 +3,25 @@ trait AttributesArrayAccessTrait
{ {
public $attributes = []; public $attributes = [];
/** public function offsetExists($offset): bool
* @todo Add bool return type when Stud.IP requires PHP8 minimal
*/
#[ReturnTypeWillChange]
public function offsetExists($offset)
{ {
return isset($this->attributes[$offset]); return isset($this->attributes[$offset]);
} }
/** /**
* @param $offset * @param string $offset
* @return mixed
*
* @todo Add mixed return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetGet($offset): mixed
public function offsetGet($offset)
{ {
return $this->attributes[$offset]; return $this->attributes[$offset];
} }
/** public function offsetSet($offset, $value): void
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/
#[ReturnTypeWillChange]
public function offsetSet($offset, $value)
{ {
$this->attributes[$offset] = $value; $this->attributes[$offset] = $value;
} }
/** public function offsetUnset($offset): void
* @todo Add void return type when Stud.IP requires PHP8 minimal
*/
#[ReturnTypeWillChange]
public function offsetUnset($offset)
{ {
unset($this->attributes[$offset]); unset($this->attributes[$offset]);
} }
......
...@@ -112,46 +112,33 @@ class StandardFile implements FileType, ArrayAccess, StandardFileInterface ...@@ -112,46 +112,33 @@ class StandardFile implements FileType, ArrayAccess, StandardFileInterface
/** /**
* ArrayAccess: Check whether the given offset exists. * ArrayAccess: Check whether the given offset exists.
*
* @todo Add bool return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetExists($offset): bool
public function offsetExists($offset)
{ {
return $this->__isset($offset); return $this->__isset($offset);
} }
/** /**
* ArrayAccess: Get the value at the given 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): mixed
public function offsetGet($offset)
{ {
return $this->__get($offset); return $this->__get($offset);
} }
/** /**
* ArrayAccess: Set the value at the given 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): void
public function offsetSet($offset, $value)
{ {
$this->__set($offset, $value); $this->__set($offset, $value);
} }
/** /**
* ArrayAccess: unset the value at the given offset (not applicable) * 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): void
public function offsetUnset($offset)
{ {
} }
/** /**
......
...@@ -51,46 +51,33 @@ class UnknownFileType implements FileType, ArrayAccess ...@@ -51,46 +51,33 @@ class UnknownFileType implements FileType, ArrayAccess
/** /**
* ArrayAccess: Check whether the given offset exists. * ArrayAccess: Check whether the given offset exists.
*
* @todo Add bool return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function offsetExists($offset): bool
public function offsetExists($offset)
{ {
return $this->__isset($offset); return $this->__isset($offset);
} }
/** /**
* ArrayAccess: Get the value at the given 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): mixed
public function offsetGet($offset)
{ {
return $this->__get($offset); return $this->__get($offset);
} }
/** /**
* ArrayAccess: Set the value at the given 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): void
public function offsetSet($offset, $value)
{ {
$this->__set($offset, $value); $this->__set($offset, $value);
} }
/** /**
* ArrayAccess: unset the value at the given offset (not applicable) * 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): void
public function offsetUnset($offset)
{ {
} }
/** /**
* @inheritDoc * @inheritDoc
......
...@@ -256,11 +256,8 @@ class DataField extends SimpleORMap implements PrivacyObject ...@@ -256,11 +256,8 @@ class DataField extends SimpleORMap implements PrivacyObject
* Specialized count method that returns the number of concrete entries. * Specialized count method that returns the number of concrete entries.
* *
* @return int number of entries * @return int number of entries
*
* @todo Add int return type when Stud.IP requires PHP8 minimal
*/ */
#[ReturnTypeWillChange] public function count(): int
public function count()
{ {
return DatafieldEntryModel::countBySQL('datafield_id = ?', [$this->id]); return DatafieldEntryModel::countBySQL('datafield_id = ?', [$this->id]);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment