From 89512696839235e4b3d2ca135917ae038ff5fc3c Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Wed, 6 Jul 2022 13:25:06 +0000
Subject: [PATCH] fixes 'Method/function should return XY but return statement
 is missing', fixes #1278

Closes #1278

Merge request studip/studip!783
---
 lib/activities/CoursewareContext.php          | 14 +++++---
 lib/classes/Config.class.php                  |  8 +++--
 lib/classes/Context.php                       | 12 +++++--
 lib/classes/CronJob.class.php                 |  4 ---
 lib/classes/ForumEntry.php                    | 12 ++-----
 lib/classes/MultiDimArrayObject.class.php     |  6 ++--
 lib/classes/MvvQuickSearch.php                |  2 +-
 lib/classes/RangeConfig.class.php             |  2 +-
 lib/classes/SemBrowse.class.php               |  6 ++--
 lib/classes/Seminar.class.php                 |  5 +--
 lib/classes/StudipCache.class.php             |  2 +-
 lib/classes/StudipLock.class.php              |  1 +
 lib/classes/StudipMemoryCache.class.php       |  4 ++-
 lib/classes/StudipPDO.class.php               |  1 +
 lib/classes/StudygroupModel.php               | 34 -------------------
 lib/classes/TwoFactorAuth.php                 | 12 +++----
 lib/classes/Visibility.php                    |  7 +---
 lib/classes/admission/CourseSet.class.php     |  2 --
 .../auth_plugins/StudipAuthAbstract.class.php |  4 +--
 lib/classes/calendar/SingleCalendar.php       | 30 +++++++++-------
 .../AdvancedBasicDataWizardStep.php           | 13 ++++---
 .../coursewizardsteps/BasicDataWizardStep.php |  2 ++
 .../globalsearch/GlobalSearchCalendar.php     | 21 +++++++-----
 .../globalsearch/GlobalSearchForum.php        |  2 ++
 lib/classes/searchtypes/SQLSearch.class.php   |  8 +++--
 .../searchtypes/StandardSearch.class.php      |  4 +++
 lib/elearning/ConnectedCMS.class.php          |  7 +---
 lib/elearning/ConnectedUser.class.php         | 22 ++++++------
 lib/elearning/ELearningUtils.class.php        |  2 --
 lib/elearning/Ilias3ConnectedCMS.class.php    |  4 +--
 .../Ilias3ConnectedPermissions.class.php      |  2 ++
 lib/elearning/Ilias3ConnectedUser.class.php   | 27 ++++++---------
 lib/elearning/Ilias3ContentModule.class.php   |  2 ++
 lib/elearning/Ilias4ConnectedCMS.class.php    |  1 -
 lib/elearning/ObjectConnections.class.php     | 12 +++----
 lib/ilias_interface/ConnectedIlias.class.php  |  8 ++---
 lib/ilias_interface/IliasModule.class.php     |  2 ++
 .../IliasObjectConnections.class.php          |  4 ++-
 lib/ilias_interface/IliasSoap.class.php       |  2 +-
 lib/ilias_interface/IliasUser.class.php       |  7 ++--
 lib/migrations/Migration.php                  |  1 +
 lib/models/CalendarEvent.class.php            |  8 +++--
 lib/models/CourseDate.class.php               |  3 +-
 .../Courseware/Filesystem/PublicFolder.php    |  2 ++
 lib/models/FileRef.php                        |  4 ++-
 lib/models/Institute.class.php                |  1 +
 lib/models/OERHostOERSI.php                   |  2 +-
 lib/models/PersonalNotifications.class.php    |  2 --
 lib/models/SeminarCycleDate.class.php         |  6 +++-
 lib/models/SimpleORMap.class.php              |  6 ++--
 lib/models/SimpleORMapCollection.class.php    |  4 ++-
 lib/models/User.class.php                     |  8 +++--
 lib/modules/ConsultationModule.class.php      |  6 ++--
 lib/modules/EvaluationsWidget.php             | 30 ++++++++--------
 lib/modules/FeedbackModule.class.php          |  2 ++
 lib/modules/LtiToolModule.class.php           |  8 +++--
 lib/object.inc.php                            |  3 +-
 lib/phplib/Seminar_Auth.class.php             |  7 ++--
 lib/phplib/Seminar_Perm.class.php             |  4 ++-
 lib/phplib/Seminar_Register_Auth.class.php    | 16 +++++----
 lib/plugins/core/PortalPlugin.class.php       |  2 +-
 lib/raumzeit/CycleData.class.php              |  6 ++--
 lib/showNews.inc.php                          |  7 ++--
 63 files changed, 233 insertions(+), 225 deletions(-)

diff --git a/lib/activities/CoursewareContext.php b/lib/activities/CoursewareContext.php
index a7bd83b7328..817deb49d36 100755
--- a/lib/activities/CoursewareContext.php
+++ b/lib/activities/CoursewareContext.php
@@ -29,28 +29,32 @@ class CoursewareContext extends Context
 
     public function getContextType()
     {
-        if($this->context == 'user') {
+        if ($this->context === 'user') {
             return \Context::USER;
         }
 
-        if ($this->content == 'course') {
+        if ($this->context === 'course') {
             return \Context::COURSE;
         }
+
+        throw new UnexpectedValueException("Unknown context type {$this->context}");
     }
 
     public function getContextFullname($format = 'default')
     {
-        if($this->context == 'user') {
+        if ($this->context === 'user') {
             $user = \User::find($this->range_id);
 
             return $user->getFullname($format);
         }
 
-        if($this->context == 'course') {
+        if ($this->context === 'course') {
             $course = \Course::find($this->range_id);
 
             return $course->getFullname($format);
         }
+
+        throw new UnexpectedValueException("Unknown context {$this->context}");
     }
 
-}
\ No newline at end of file
+}
diff --git a/lib/classes/Config.class.php b/lib/classes/Config.class.php
index a36bde9874e..f977bb9d5c3 100644
--- a/lib/classes/Config.class.php
+++ b/lib/classes/Config.class.php
@@ -123,7 +123,7 @@ class Config implements ArrayAccess, Countable, IteratorAggregate
      * for compatibility reasons an existing variable in global
      * namespace with the same name is also returned
      * @param string $field
-     * @return Ambigous
+     * @return mixed
      */
     public function getValue($field)
     {
@@ -133,13 +133,15 @@ class Config implements ArrayAccess, Countable, IteratorAggregate
         if (isset($GLOBALS[$field]) && !isset($_REQUEST[$field])) {
             return $GLOBALS[$field];
         }
+
+        return null;
     }
 
     /**
      * set config entry to given value, but don't store it
      * in database
      * @param string $field
-     * @param unknown_type $value
+     * @param mixed $value
      * @return
      */
     public function setValue($field, $value)
@@ -324,7 +326,7 @@ class Config implements ArrayAccess, Countable, IteratorAggregate
      * @param string name of entry
      * @param array data to insert as assoc array
      * @throws InvalidArgumentException
-     * @return Ambigous <NULL, ConfigEntry>
+     * @return null|ConfigEntry
      */
     public function create($field, $data = [])
     {
diff --git a/lib/classes/Context.php b/lib/classes/Context.php
index f43bd38135b..09b3a1bb423 100644
--- a/lib/classes/Context.php
+++ b/lib/classes/Context.php
@@ -131,12 +131,12 @@ class Context
         switch (self::getType()) {
             case self::COURSE:
                 return 'sem';
-                break;
 
             case self::INSTITUTE:
                 return 'inst';
-                break;
         }
+
+        throw new UnexpectedValueException('Invalid context type');
     }
 
     /**
@@ -151,9 +151,13 @@ class Context
     {
         if (self::isCourse()) {
             return self::get()->status;
-        } else if (Context::isInstitute()) {
+        }
+
+        if (self::isInstitute()) {
             return self::get()->type;
         }
+
+        throw new UnexpectedValueException('Invalid context type');
     }
 
     /**
@@ -172,6 +176,8 @@ class Context
             case self::INSTITUTE:
                 return _('Einrichtung');
         }
+
+        throw new UnexpectedValueException('Invalid context type');
     }
 
     /**
diff --git a/lib/classes/CronJob.class.php b/lib/classes/CronJob.class.php
index db8a0333124..1e7fb412123 100644
--- a/lib/classes/CronJob.class.php
+++ b/lib/classes/CronJob.class.php
@@ -126,10 +126,6 @@ abstract class CronJob
 
     /**
      * Unregisters a previously registered task.
-     *
-     * @param String $task_id Id of the task to be unregistered
-     * @return CronjobScheduler to allow chaining
-     * @throws InvalidArgumentException when no task with the given id exists
      */
     public static function unregister()
     {
diff --git a/lib/classes/ForumEntry.php b/lib/classes/ForumEntry.php
index aeab01705c2..95721d75c2f 100644
--- a/lib/classes/ForumEntry.php
+++ b/lib/classes/ForumEntry.php
@@ -605,8 +605,6 @@ class ForumEntry  implements PrivacyObject
                 $postings = ForumEntry::getLastPostings($postings);
                 return ['list' => $postings, 'count' => $list['count']];
 
-                break;
-
             case 'list':
                 $constraint = ForumEntry::getConstraints($parent_id);
 
@@ -632,11 +630,9 @@ class ForumEntry  implements PrivacyObject
                 $postings = ForumEntry::getLastPostings($postings);
 
                 return ['list' => $postings, 'count' => $count];
-                break;
 
             case 'postings':
                 return ForumEntry::getEntries($parent_id, ForumEntry::WITH_CHILDS, '', 'ASC', $start);
-                break;
 
             case 'newest':
                 $constraint = ForumEntry::getConstraints($parent_id);
@@ -678,16 +674,13 @@ class ForumEntry  implements PrivacyObject
 
                 // return results
                 return ['list' => $postings, 'count' => $stmt_count->fetchColumn()];
-                break;
 
             case 'latest':
                 return ForumEntry::getEntries($parent_id, ForumEntry::WITH_CHILDS, '', 'DESC', $start);
-                break;
 
             case 'favorites':
                 $add = "AND ou.topic_id IS NOT NULL";
                 return ForumEntry::getEntries($parent_id, ForumEntry::WITH_CHILDS, $add, 'DESC', $start);
-                break;
 
             case 'dump':
                 $constraint = ForumEntry::getConstraints($parent_id);
@@ -703,7 +696,6 @@ class ForumEntry  implements PrivacyObject
                 $stmt->execute([$seminar_id, $constraint['lft'], $constraint['rgt']]);
 
                 return ForumEntry::parseEntries($stmt->fetchAll(PDO::FETCH_ASSOC));
-                break;
 
             case 'flat':
                 $constraint = ForumEntry::getConstraints($parent_id);
@@ -744,7 +736,6 @@ class ForumEntry  implements PrivacyObject
                 }
 
                 return ['list' => $posting_list, 'count' => $count];
-                break;
 
             case 'depth_to_large':
                 $constraint = ForumEntry::getConstraints($parent_id);
@@ -757,8 +748,9 @@ class ForumEntry  implements PrivacyObject
                 $count = DBManager::get()->query("SELECT FOUND_ROWS()")->fetchColumn();
 
                 return ['list' => $stmt->fetchAll(PDO::FETCH_ASSOC), 'count' => $count];
-                break;
         }
+
+        throw new InvalidArgumentException("Invalid type {$type}");
     }
 
     /**
diff --git a/lib/classes/MultiDimArrayObject.class.php b/lib/classes/MultiDimArrayObject.class.php
index fb218febb63..bcbdee49fe5 100644
--- a/lib/classes/MultiDimArrayObject.class.php
+++ b/lib/classes/MultiDimArrayObject.class.php
@@ -36,7 +36,7 @@ class MultiDimArrayObject extends StudipArrayObject
      * Exchange the array for another one.
      *
      * @param  array|ArrayObject $data
-     * @return
+     * @return array
      */
     public function exchangeArray($data)
     {
@@ -51,8 +51,11 @@ class MultiDimArrayObject extends StudipArrayObject
             $data = (array) $data;
         }
 
+        $storage = $this->storage;
+
         $this->storage = $this->recursiveArrayToArrayObjects($data);
 
+        return $storage;
     }
 
     /**
@@ -124,4 +127,3 @@ class MultiDimArrayObject extends StudipArrayObject
         return $data;
     }
 }
-
diff --git a/lib/classes/MvvQuickSearch.php b/lib/classes/MvvQuickSearch.php
index bb49056983b..2f55646bebc 100644
--- a/lib/classes/MvvQuickSearch.php
+++ b/lib/classes/MvvQuickSearch.php
@@ -45,7 +45,7 @@ class MvvQuickSearch extends SQLSearch
         if (!$id) {
             return $this->zusatz;
         }
-        parent::getAvatarImageTag($id, $size = Avatar::SMALL, $options);
+        return parent::getAvatarImageTag($id, $size = Avatar::SMALL, $options);
     }
     
     public function setQsName($qs_name)
diff --git a/lib/classes/RangeConfig.class.php b/lib/classes/RangeConfig.class.php
index a1e1bb9b300..17375d15e70 100644
--- a/lib/classes/RangeConfig.class.php
+++ b/lib/classes/RangeConfig.class.php
@@ -194,7 +194,7 @@ class RangeConfig extends Config
             $data['range'] = static::RANGE_TYPE;
         }
 
-        parent::create($field, $data);
+        return parent::create($field, $data);
     }
 
     /**
diff --git a/lib/classes/SemBrowse.class.php b/lib/classes/SemBrowse.class.php
index ef6136c5df0..6e32f775ae7 100644
--- a/lib/classes/SemBrowse.class.php
+++ b/lib/classes/SemBrowse.class.php
@@ -1147,9 +1147,9 @@ class SemBrowse {
      *
      * @param string $target
      * @param string $option_name
-     * @return \Navigation
+     * @return Navigation|null
      */
-    public static function getSearchOptionNavigation($target, $option_name = null)
+    public static function getSearchOptionNavigation($target, $option_name = null): ?Navigation
     {
         // return first visible search option
         if (is_null($option_name)) {
@@ -1227,6 +1227,8 @@ class SemBrowse {
                             'option'        => $option_name
                         ], true));
         }
+
+        return null;
     }
 
     /**
diff --git a/lib/classes/Seminar.class.php b/lib/classes/Seminar.class.php
index 00108aa35a2..7f8886ca42b 100644
--- a/lib/classes/Seminar.class.php
+++ b/lib/classes/Seminar.class.php
@@ -2344,14 +2344,15 @@ class Seminar
      * returns StudipModule object for given slot, null when deactivated or not available
      *
      * @param string $slot
-     * @return StudipModule
+     * @return StudipModule|null
      */
-    public function getSlotModule($slot)
+    public function getSlotModule($slot): ?StudipModule
     {
         $module = 'Core' . ucfirst($slot);
         if ($this->course->isToolActive($module)) {
             return PluginEngine::getPlugin($module);
         }
+        return null;
     }
 
     /**
diff --git a/lib/classes/StudipCache.class.php b/lib/classes/StudipCache.class.php
index ac308f27014..79e80e36f5f 100644
--- a/lib/classes/StudipCache.class.php
+++ b/lib/classes/StudipCache.class.php
@@ -54,7 +54,7 @@ interface StudipCache
      *
      * @param string $name     the item's key.
      * @param mixed  $content  the item's content (will be serialized if necessary).
-     * @param int    $expired  the item's expiry time in seconds. Optional, defaults to 12h.
+     * @param int    $expires  the item's expiry time in seconds. Optional, defaults to 12h.
      *
      * @return bool     returns TRUE on success or FALSE on failure.
      */
diff --git a/lib/classes/StudipLock.class.php b/lib/classes/StudipLock.class.php
index 8152d948eb5..601db8b10ac 100644
--- a/lib/classes/StudipLock.class.php
+++ b/lib/classes/StudipLock.class.php
@@ -82,6 +82,7 @@ class StudipLock
         if (self::$current) {
             return DBManager::get()->fetchColumn("SELECT RELEASE_LOCK(?)", [self::lockname(self::$current)]);
         }
+        return 0;
     }
 
     /**
diff --git a/lib/classes/StudipMemoryCache.class.php b/lib/classes/StudipMemoryCache.class.php
index 3946b345477..395475d415c 100644
--- a/lib/classes/StudipMemoryCache.class.php
+++ b/lib/classes/StudipMemoryCache.class.php
@@ -57,11 +57,13 @@ class StudipMemoryCache implements StudipCache
      * @returns mixed  returns TRUE on success or FALSE on failure.
      *
      */
-    public function write($name, $content, $expire = self::DEFAULT_EXPIRATION)
+    public function write($name, $content, $expires = self::DEFAULT_EXPIRATION)
     {
         $this->memory_cache[$name] = [
             'expires' => time() + $expire,
             'data'    => $content,
         ];
+
+        return true;
     }
 }
diff --git a/lib/classes/StudipPDO.class.php b/lib/classes/StudipPDO.class.php
index 8e67c342931..a758b1028df 100644
--- a/lib/classes/StudipPDO.class.php
+++ b/lib/classes/StudipPDO.class.php
@@ -230,6 +230,7 @@ class StudipPDO extends PDO
         if ($ok === true) {
             return $st->rowCount();
         }
+        return 0;
     }
 
     /**
diff --git a/lib/classes/StudygroupModel.php b/lib/classes/StudygroupModel.php
index be4575e9cc5..76899f107a3 100644
--- a/lib/classes/StudygroupModel.php
+++ b/lib/classes/StudygroupModel.php
@@ -482,40 +482,6 @@ class StudygroupModel
         return (bool) $stmt->fetchColumn();
     }
 
-    /**
-     * callback function - used to compare sequences of studygroup statuses
-     *
-     * @param array status a
-     * @param array status b
-     * @return int ordering
-     */
-    public static function compare_status($a, $b)
-    {
-        if ($a['status'] === $b['status']) {
-            return strnatcmp($a['fullname'], $b['fullname']);
-        }
-
-        if ($a['status'] === 'dozent') {
-            if ($b['status'] === 'tutor') {
-                return -1;
-            } elseif ($b['status'] === 'autor') {
-                return -1;
-            }
-        } elseif ($a['status'] === 'tutor') {
-            if ($b['status'] === 'dozent') {
-                return 1;
-            } elseif ($b['status'] === 'autor') {
-                return -1;
-            }
-        } elseif ($a['status'] === 'autor') {
-            if ($b['status'] === 'tutor') {
-                return 1;
-            } elseif ($b['status'] === 'dozent') {
-                return 1;
-            }
-        }
-    }
-
     /**
      * Checks for a given seminar_id whether a course is a studygroup
      *
diff --git a/lib/classes/TwoFactorAuth.php b/lib/classes/TwoFactorAuth.php
index ef7e6685aa8..7fd9f45edb9 100644
--- a/lib/classes/TwoFactorAuth.php
+++ b/lib/classes/TwoFactorAuth.php
@@ -171,9 +171,8 @@ final class TwoFactorAuth
      * @param  string $text   Text to display to the user
      * @param  array  $data   Optional additional data to pass to the
      *                        confirmation screen (for internal use)
-     * @return bool
      */
-    public function confirm($action, $text, array $data = [])
+    public function confirm($action, $text, array $data = []): void
     {
         if (isset($_SESSION[self::SESSION_CONFIRMATIONS])
             && is_array($_SESSION[self::SESSION_CONFIRMATIONS])
@@ -183,12 +182,11 @@ final class TwoFactorAuth
                 $_SESSION[self::SESSION_CONFIRMATIONS],
                 [$action]
             );
-            return true;
+        } else {
+            $this->showConfirmationScreen($text, $data + [
+                'confirm' => $action,
+            ]);
         }
-
-        $this->showConfirmationScreen($text, $data + [
-            'confirm' => $action,
-        ]);
     }
 
     /**
diff --git a/lib/classes/Visibility.php b/lib/classes/Visibility.php
index c4499492089..ce191d2ab8f 100644
--- a/lib/classes/Visibility.php
+++ b/lib/classes/Visibility.php
@@ -147,7 +147,7 @@ class Visibility
      * (under the usage of a userid) therefore all identifier set for one user
      * MUST be unique.
      *
-     * @param int|string $parent Determines the parent of the visibility to add.
+     * @param int|string $parent_identifier Determines the parent of the visibility to add.
      * Use the direct visibilityid of the parent visibility or the identifier.
      * If the visibility should be created on the top level the value has to be
      * 0. Plugins creating a privacysetting will automaticly be added to the
@@ -159,9 +159,6 @@ class Visibility
      * 0 - The setting is only a header without any options
      * 1 (Default) - Normal setting
      *
-     * @param string $user Userid of the user that should be added the visibility.
-     * Default: The current logged on user
-     *
      * @param int $default int representation of the visibility that should be
      * set. Use with caution since the API provides the easy change of the
      * visibility int representation
@@ -170,8 +167,6 @@ class Visibility
      * Important: If addPrivacySetting is called in a file of a plugin there is
      * no need to set the pluginid manually, because the API will normally find
      * it
-     *
-     * @return int the created visibilityid
      */
     public static function addPrivacySettingForAll($name, $identifier = "", $parent_identifier = 0, $category = 1, $default = null, $pluginid = null)
     {
diff --git a/lib/classes/admission/CourseSet.class.php b/lib/classes/admission/CourseSet.class.php
index 3ea4997183c..e79f4c08c94 100644
--- a/lib/classes/admission/CourseSet.class.php
+++ b/lib/classes/admission/CourseSet.class.php
@@ -223,8 +223,6 @@ class CourseSet
 
     /**
      * Starts the seat distribution algorithm.
-     *
-     * @return CourseSet
      */
     public function distributeSeats() {
         if ($this->algorithm) {
diff --git a/lib/classes/auth_plugins/StudipAuthAbstract.class.php b/lib/classes/auth_plugins/StudipAuthAbstract.class.php
index 008ed870967..a21d1513aa0 100644
--- a/lib/classes/auth_plugins/StudipAuthAbstract.class.php
+++ b/lib/classes/auth_plugins/StudipAuthAbstract.class.php
@@ -361,9 +361,7 @@ class StudipAuthAbstract
      * place special treatment of new users here
      *
      * @access private
-     * @param
-     *            User the user object
-     * @return bool
+     * @param User $user the user object
      */
     function doNewUserInit($user)
     {
diff --git a/lib/classes/calendar/SingleCalendar.php b/lib/classes/calendar/SingleCalendar.php
index 60cef5ece86..da2987f246c 100644
--- a/lib/classes/calendar/SingleCalendar.php
+++ b/lib/classes/calendar/SingleCalendar.php
@@ -131,7 +131,7 @@ class SingleCalendar
         if (!$attendee_ids) {
             $attendee_ids = [$GLOBALS['user']->id];
         }
-        if (count($attendee_ids) == 1) {
+        if (count($attendee_ids) === 1) {
             if (!$this->havePermission(Calendar::PERMISSION_WRITABLE)) {
                 return false;
             }
@@ -142,19 +142,21 @@ class SingleCalendar
                 $this->sendStoreMessage($event, $is_new);
             }
             return $stored;
-        } else {
-            if (in_array($this->getRangeId(), $attendee_ids)) {
-                // set default status if the organizer is an attendee...
-                $event->group_status = CalendarEvent::PARTSTAT_TENTATIVE;
-            }
-            if ($event->isNew()) {
-                return $this->storeAttendeeEvents($event, $attendee_ids);
-            } else {
-                if ($event->havePermission(Event::PERMISSION_WRITABLE)) {
-                    return $this->storeAttendeeEvents($event, $attendee_ids);
-                }
-            }
         }
+
+        if (in_array($this->getRangeId(), $attendee_ids)) {
+            // set default status if the organizer is an attendee...
+            $event->group_status = CalendarEvent::PARTSTAT_TENTATIVE;
+        }
+        if ($event->isNew()) {
+            return $this->storeAttendeeEvents($event, $attendee_ids);
+        }
+
+        if (!$event->havePermission(Event::PERMISSION_WRITABLE)) {
+            return false;
+        }
+
+        return $this->storeAttendeeEvents($event, $attendee_ids);
     }
 
     /**
@@ -955,6 +957,8 @@ class SingleCalendar
                 $events_created[implode('', (array) $event->getId()) . $start] = $new_event;
             }
         }
+
+        return true;
     }
 
     /**
diff --git a/lib/classes/coursewizardsteps/AdvancedBasicDataWizardStep.php b/lib/classes/coursewizardsteps/AdvancedBasicDataWizardStep.php
index 595c5fe5202..780f837fd1f 100644
--- a/lib/classes/coursewizardsteps/AdvancedBasicDataWizardStep.php
+++ b/lib/classes/coursewizardsteps/AdvancedBasicDataWizardStep.php
@@ -39,13 +39,16 @@ class AdvancedBasicDataWizardStep extends BasicDataWizardStep
         $factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'].'/app/views/course/wizard/steps');
         $template = $factory->open('advancedbasicdata/index');
 
-        if ($template = $this->setupTemplateAttributes($template, $values, $stepnumber, $temp_id)) {
-            $values = $this->makeI18N($values[__CLASS__], ['name', 'description', 'subtitle', 'kind']);
+        $template = $this->setupTemplateAttributes($template, $values, $stepnumber, $temp_id);
+        if (!$template) {
+            return '';
+        }
 
-            $template->set_attribute('values', array_merge($template->values, $values));
+        $values = $this->makeI18N($values[__CLASS__], ['name', 'description', 'subtitle', 'kind']);
 
-            return $template->render();
-        }
+        $template->set_attribute('values', array_merge($template->values, $values));
+
+        return $template->render();
     }
 
     /**
diff --git a/lib/classes/coursewizardsteps/BasicDataWizardStep.php b/lib/classes/coursewizardsteps/BasicDataWizardStep.php
index 14793ea319e..b3fb7fe34d3 100644
--- a/lib/classes/coursewizardsteps/BasicDataWizardStep.php
+++ b/lib/classes/coursewizardsteps/BasicDataWizardStep.php
@@ -38,6 +38,8 @@ class BasicDataWizardStep implements CourseWizardStep
         if ($this->setupTemplateAttributes($tpl, $values, $stepnumber, $temp_id)) {
             return $tpl->render();
         }
+
+        return '';
     }
 
     protected function setupTemplateAttributes($tpl, $values, $stepnumber, $temp_id)
diff --git a/lib/classes/globalsearch/GlobalSearchCalendar.php b/lib/classes/globalsearch/GlobalSearchCalendar.php
index edcb018146b..8682226744b 100644
--- a/lib/classes/globalsearch/GlobalSearchCalendar.php
+++ b/lib/classes/globalsearch/GlobalSearchCalendar.php
@@ -46,18 +46,21 @@ class GlobalSearchCalendar extends GlobalSearchModule
     public static function getSQL($search, $filter, $limit)
     {
         $time    = strtotime($search);
+
+        if ($time === false) {
+            return '';
+        }
+
         $endtime = $time + 24 * 60 * 60;
         $user_id = DBManager::get()->quote($GLOBALS['user']->id);
 
-        if ($time) {
-            return "SELECT SQL_CALC_FOUND_ROWS `date`, `end_time`, `seminar_id`
-                    FROM `termine`
-                    JOIN `seminar_user` ON (`range_id` = `seminar_id`)
-                    WHERE `user_id` = {$user_id}
-                      AND `date` BETWEEN {$time} AND {$endtime}
-                    ORDER BY `date`
-                    LIMIT " . $limit;
-        }
+        return "SELECT SQL_CALC_FOUND_ROWS `date`, `end_time`, `seminar_id`
+                FROM `termine`
+                JOIN `seminar_user` ON (`range_id` = `seminar_id`)
+                WHERE `user_id` = {$user_id}
+                  AND `date` BETWEEN {$time} AND {$endtime}
+                ORDER BY `date`
+                LIMIT " . $limit;
     }
 
     /**
diff --git a/lib/classes/globalsearch/GlobalSearchForum.php b/lib/classes/globalsearch/GlobalSearchForum.php
index 37efd26930b..8c152c888f2 100644
--- a/lib/classes/globalsearch/GlobalSearchForum.php
+++ b/lib/classes/globalsearch/GlobalSearchForum.php
@@ -166,6 +166,8 @@ class GlobalSearchForum extends GlobalSearchModule implements GlobalSearchFullte
 
             return $result;
         }
+
+        return [];
     }
 
     /**
diff --git a/lib/classes/searchtypes/SQLSearch.class.php b/lib/classes/searchtypes/SQLSearch.class.php
index 7aac0a3df88..f69a65e4d28 100644
--- a/lib/classes/searchtypes/SQLSearch.class.php
+++ b/lib/classes/searchtypes/SQLSearch.class.php
@@ -86,7 +86,6 @@ class SQLSearch extends SearchType
      * returns an adress of the avatar of the searched item (if avatar enabled)
      *
      * @param string $id id of the item which can be username, user_id, Seminar_id or Institut_id
-     * @param string $size enum(NORMAL, SMALL, MEDIUM): size of the avatar-image
      *
      * @return string adress of an image
      */
@@ -102,6 +101,8 @@ class SQLSearch extends SearchType
                 return CourseAvatar::getAvatar($id)->getURL(Avatar::SMALL);
             case "Institut_id":
                 return InstituteAvatar::getAvatar($id)->getURL(Avatar::SMALL);
+            default:
+                return '';
         }
     }
 
@@ -109,7 +110,8 @@ class SQLSearch extends SearchType
      * returns an html tag of the image of the searched item (if avatar enabled)
      *
      * @param string $id id of the item which can be username, user_id, Seminar_id or Institut_id
-     * @param constant $size enum(NORMAL, SMALL, MEDIUM): size of the avatar
+     * @param string $size enum(NORMAL, SMALL, MEDIUM): size of the avatar
+     * @param array $options
      *
      * @return string like "<img src="...avatar.jpg" ... >"
      */
@@ -125,6 +127,8 @@ class SQLSearch extends SearchType
                 return CourseAvatar::getAvatar($id)->getImageTag($size, $options);
             case "Institut_id":
                 return InstituteAvatar::getAvatar($id)->getImageTag($size, $options);
+            default:
+                return '';
         }
     }
 
diff --git a/lib/classes/searchtypes/StandardSearch.class.php b/lib/classes/searchtypes/StandardSearch.class.php
index 2f1be430cde..62642fca5f7 100644
--- a/lib/classes/searchtypes/StandardSearch.class.php
+++ b/lib/classes/searchtypes/StandardSearch.class.php
@@ -78,6 +78,8 @@ class StandardSearch extends SQLSearch
                 return _("Arbeitsgruppe suchen");
             case "Institut_id":
                 return _("Einrichtung suchen");
+            default:
+                throw new UnexpectedValueException("Invalid search type {$this->search}");
         }
     }
 
@@ -174,6 +176,8 @@ class StandardSearch extends SQLSearch
                             "OR Institute.email LIKE :input " .
                             "OR range_tree.name LIKE :input " .
                         "ORDER BY Institute.Name";
+            default:
+                throw new UnexpectedValueException("Invalid search type {$this->search}");
         }
     }
 
diff --git a/lib/elearning/ConnectedCMS.class.php b/lib/elearning/ConnectedCMS.class.php
index 41640b7e532..0aac5261f4f 100644
--- a/lib/elearning/ConnectedCMS.class.php
+++ b/lib/elearning/ConnectedCMS.class.php
@@ -434,15 +434,10 @@ class ConnectedCMS
     }
 
     /**
-    * terminate
-    *
-    * dummy-method. returns false. can be overwritten by subclass.
-    * @access public
-    * @return boolean returns false
+    * dummy-method. can be overwritten by subclass.
     */
     public function terminate()
     {
-        return false;
     }
 
     public function deleteConnectedModules($object_id){
diff --git a/lib/elearning/ConnectedUser.class.php b/lib/elearning/ConnectedUser.class.php
index 9351955ab21..3c74a14589a 100644
--- a/lib/elearning/ConnectedUser.class.php
+++ b/lib/elearning/ConnectedUser.class.php
@@ -100,6 +100,8 @@ class ConnectedUser
         $this->category          = $data['external_user_category'];
         $this->type              = $data['external_user_type'];
         $this->is_connected      = true;
+
+        return true;
     }
 
     /**
@@ -168,13 +170,10 @@ class ConnectedUser
     /**
     * update user-account
     *
-    * dummy-method. returns false. must be overwritten by subclass.
-    * @access public
-    * @return boolean returns false
+    * dummy-method. must be overwritten by subclass.
     */
-    function updateUser()
+    public function updateUser()
     {
-        return false;
     }
 
     /**
@@ -464,13 +463,12 @@ class ConnectedUser
     }
 
     /**
-    * save connection for user-account
-    *
-    * saves user-connection to database and sets type for actual user
-    * @access public
-    * @param string $user_type user-type
-    */
-    function setConnection($user_type)
+     * save connection for user-account
+     *
+     * saves user-connection to database and sets type for actual user
+     * @param string $user_type user-type
+     */
+    public function setConnection($user_type)
     {
         $this->setUserType($user_type);
 
diff --git a/lib/elearning/ELearningUtils.class.php b/lib/elearning/ELearningUtils.class.php
index c5b22d1a362..ad49569d013 100644
--- a/lib/elearning/ELearningUtils.class.php
+++ b/lib/elearning/ELearningUtils.class.php
@@ -446,8 +446,6 @@ class ELearningUtils
      * delete cms-data
      *
      * deletes all data belonging to the specified cms from stud.ip database
-     *
-     * @return boolean successful
      */
     public static function deleteCMSData($cms_type)
     {
diff --git a/lib/elearning/Ilias3ConnectedCMS.class.php b/lib/elearning/Ilias3ConnectedCMS.class.php
index 83e6921b3f7..69f1e529f53 100644
--- a/lib/elearning/Ilias3ConnectedCMS.class.php
+++ b/lib/elearning/Ilias3ConnectedCMS.class.php
@@ -337,10 +337,8 @@ class Ilias3ConnectedCMS extends ConnectedCMS
     * terminate
     *
     * terminates connection.
-    * @access public
-    * @return boolean returns false
     */
-    function terminate()
+    public function terminate()
     {
 //      $this->soap_client->logout();
         $this->soap_client->saveCacheData();
diff --git a/lib/elearning/Ilias3ConnectedPermissions.class.php b/lib/elearning/Ilias3ConnectedPermissions.class.php
index e3c3b208405..17319d7298e 100644
--- a/lib/elearning/Ilias3ConnectedPermissions.class.php
+++ b/lib/elearning/Ilias3ConnectedPermissions.class.php
@@ -168,6 +168,8 @@ class Ilias3ConnectedPermissions extends ConnectedPermissions
         if (!$this->getContentModulePerms($course_id)) {
             $messages["info"] .= _("Für den zugeordneten ILIAS-Kurs konnten keine Berechtigungen ermittelt werden.") . "<br>";
         }
+
+        return true;
     }
 
     /**
diff --git a/lib/elearning/Ilias3ConnectedUser.class.php b/lib/elearning/Ilias3ConnectedUser.class.php
index 90170f1551d..ef985295e0e 100644
--- a/lib/elearning/Ilias3ConnectedUser.class.php
+++ b/lib/elearning/Ilias3ConnectedUser.class.php
@@ -250,13 +250,9 @@ class Ilias3ConnectedUser extends ConnectedUser
     }
 
     /**
-    * update user
-    *
-    * update user-account
-    * @access public
-    * @return boolean returns false on error
-    */
-    function updateUser()
+     * update user-account
+     */
+    public function updateUser()
     {
     }
 
@@ -288,18 +284,17 @@ class Ilias3ConnectedUser extends ConnectedUser
     }
 
     /**
-    * set connection
-    *
-    * set user connection
-    * @access public
-    * @param string user_type user-type
-    * @return boolean returns false on error
-    */
-    function setConnection($user_type, $ignore_encrypt_passwords = false)
+     * set connection
+     *
+     * set user connection
+     * @access public
+     * @param string user_type user-type
+     */
+    public function setConnection($user_type, $ignore_encrypt_passwords = false)
     {
         global $connected_cms;
 
-        if (!$ignore_encrypt_passwords && $connected_cms[$this->cms_type]->encrypt_passwords == "md5")
+        if (!$ignore_encrypt_passwords && $connected_cms[$this->cms_type]->encrypt_passwords === "md5")
         {
 //          echo "PASSWORD-ENCRYPTION";
             $this->external_password = $this->getCryptedPassword( $this->external_password );
diff --git a/lib/elearning/Ilias3ContentModule.class.php b/lib/elearning/Ilias3ContentModule.class.php
index 95b2f8fd88f..b1c913ce3cf 100644
--- a/lib/elearning/Ilias3ContentModule.class.php
+++ b/lib/elearning/Ilias3ContentModule.class.php
@@ -122,6 +122,8 @@ class Ilias3ContentModule extends ContentModule
         }
 
 //      echo "PERM".implode($this->allowed_operations,"-");
+
+        return true;
     }
 
     /**
diff --git a/lib/elearning/Ilias4ConnectedCMS.class.php b/lib/elearning/Ilias4ConnectedCMS.class.php
index f9e566a7ba6..b8f0ea3ab14 100644
--- a/lib/elearning/Ilias4ConnectedCMS.class.php
+++ b/lib/elearning/Ilias4ConnectedCMS.class.php
@@ -79,7 +79,6 @@ class Ilias4ConnectedCMS extends Ilias3ConnectedCMS
      * checks if there are modules in the course that are not connected to the seminar
      * @access public
      * @param string $course_id course-id
-     * @return boolean successful
      */
     function updateConnections($course_id)
     {
diff --git a/lib/elearning/ObjectConnections.class.php b/lib/elearning/ObjectConnections.class.php
index fc28b9b47d1..e360f71759b 100644
--- a/lib/elearning/ObjectConnections.class.php
+++ b/lib/elearning/ObjectConnections.class.php
@@ -106,14 +106,12 @@ class ObjectConnections
      * @param string $object_id object-id (optional)
      * @return boolean connection-status
      */
-    public static function isObjectConnected($object_id = null)
+    public static function isObjectConnected($object_id)
     {
-        if (isset($object_id)) {
-            $query = "SELECT 1 FROM object_contentmodules WHERE object_id = ?";
-            $statement = DBManager::get()->prepare($query);
-            $statement->execute([$object_id]);
-            return (bool)$statement->fetchColumn();
-        }
+        $query = "SELECT 1 FROM object_contentmodules WHERE object_id = ?";
+        $statement = DBManager::get()->prepare($query);
+        $statement->execute([$object_id]);
+        return (bool)$statement->fetchColumn();
     }
 
     /**
diff --git a/lib/ilias_interface/ConnectedIlias.class.php b/lib/ilias_interface/ConnectedIlias.class.php
index c6d0497b7c9..f49487bdcff 100644
--- a/lib/ilias_interface/ConnectedIlias.class.php
+++ b/lib/ilias_interface/ConnectedIlias.class.php
@@ -114,11 +114,7 @@ class ConnectedIlias
     }
 
     /**
-     * load settings
-     *
      * load ILIAS settings from config table
-     * @access public
-     * @return string messages
      */
     public function loadSettings()
     {
@@ -912,7 +908,7 @@ class ConnectedIlias
      * creates new ilias course
      * @access public
      * @param string $studip_course_id seminar-id
-     * @return boolean successful
+     * @return string|false|null
      */
     public function addCourse($studip_course_id)
     {
@@ -1034,6 +1030,8 @@ class ConnectedIlias
             $this->CheckUserCoursePermissions($crs_id);
             return $crs_id;
         }
+
+        return null;
     }
 
     /**
diff --git a/lib/ilias_interface/IliasModule.class.php b/lib/ilias_interface/IliasModule.class.php
index 0aff13ba371..53a8f780f10 100644
--- a/lib/ilias_interface/IliasModule.class.php
+++ b/lib/ilias_interface/IliasModule.class.php
@@ -213,6 +213,8 @@ class IliasModule
             case 'add'         : return 'course/ilias_interface/edit_object_assignment/'.$this->ilias_index.'?add_module=1&ilias_module_id='.$this->id;
             case 'remove'      : return 'course/ilias_interface/edit_object_assignment/'.$this->ilias_index.'?remove_module&ilias_module_id='.$this->id;
         }
+
+        throw new InvalidArgumentException("Unknown action {$action}");
     }
 
 
diff --git a/lib/ilias_interface/IliasObjectConnections.class.php b/lib/ilias_interface/IliasObjectConnections.class.php
index c55eee7a796..87468e99615 100755
--- a/lib/ilias_interface/IliasObjectConnections.class.php
+++ b/lib/ilias_interface/IliasObjectConnections.class.php
@@ -110,8 +110,10 @@ class IliasObjectConnections
             $query = "SELECT 1 FROM object_contentmodules WHERE object_id = ? AND system_type = ?";
             $statement = DBManager::get()->prepare($query);
             $statement->execute([$object_id, $index]);
-            return (bool)$statement->fetchColumn();
+            return (bool) $statement->fetchColumn();
         }
+
+        return false;
     }
 
     /**
diff --git a/lib/ilias_interface/IliasSoap.class.php b/lib/ilias_interface/IliasSoap.class.php
index 93f34970fb1..b8977bf0e85 100644
--- a/lib/ilias_interface/IliasSoap.class.php
+++ b/lib/ilias_interface/IliasSoap.class.php
@@ -985,8 +985,8 @@ class IliasSoap extends StudipSoapClient
                     return $ret;
                 }
             }
-            return false;
         }
+        return false;
     }
 
     /**
diff --git a/lib/ilias_interface/IliasUser.class.php b/lib/ilias_interface/IliasUser.class.php
index 23968f91605..996bb85ff5f 100755
--- a/lib/ilias_interface/IliasUser.class.php
+++ b/lib/ilias_interface/IliasUser.class.php
@@ -99,6 +99,8 @@ class IliasUser
         $this->category          = $data['external_user_category'];
         $this->type              = $data['external_user_type'];
         $this->is_connected      = true;
+
+        return true;
     }
 
     /**
@@ -205,12 +207,11 @@ class IliasUser
      * set id
      *
      * returns id
-     * @access public
      * @return string id
      */
-    function setId($ilias_user_id)
+    public function setId($ilias_user_id)
     {
-        $this->id = $ilias_user_id;
+        return $this->id = $ilias_user_id;
     }
 
     /**
diff --git a/lib/migrations/Migration.php b/lib/migrations/Migration.php
index d989d5341e3..abaf7476605 100644
--- a/lib/migrations/Migration.php
+++ b/lib/migrations/Migration.php
@@ -45,6 +45,7 @@ abstract class Migration
      */
     public function description()
     {
+        return '';
     }
 
     /**
diff --git a/lib/models/CalendarEvent.class.php b/lib/models/CalendarEvent.class.php
index a7edb4aaaf5..6b4f1e0f765 100644
--- a/lib/models/CalendarEvent.class.php
+++ b/lib/models/CalendarEvent.class.php
@@ -238,7 +238,7 @@ class CalendarEvent extends SimpleORMap implements Event, PrivacyObject
      * TODO should throw an exception if input values are wrong
      *
      * @param array $r_rule
-     * @return array The values of the recurrence rule.
+     * @return array|false The values of the recurrence rule.
      */
     function setRecurrence($r_rule)
     {
@@ -453,6 +453,8 @@ class CalendarEvent extends SimpleORMap implements Event, PrivacyObject
         $this->event->duration = $rrule[7];
         $this->event->count = $r_rule['count'];
         $this->event->expire = $r_rule['expire'];
+
+        return $r_rule;
     }
 
     /**
@@ -1027,7 +1029,9 @@ class CalendarEvent extends SimpleORMap implements Event, PrivacyObject
             case 'inst':
             case 'fak':
                 return (string) $this->institute->name;
-            }
+            default:
+                return '';
+        }
     }
 
     /**
diff --git a/lib/models/CourseDate.class.php b/lib/models/CourseDate.class.php
index 91c35793406..e98308de3c1 100644
--- a/lib/models/CourseDate.class.php
+++ b/lib/models/CourseDate.class.php
@@ -196,7 +196,7 @@ class CourseDate extends SimpleORMap implements PrivacyObject
      *
      * @param mixed $topic Topic definition (might be an id, an array or an
      *                     object)
-     * @return number addition of all return values, false if none was called
+     * @return int|false number addition of all return values, false if none was called
      */
     public function addTopic($topic)
     {
@@ -205,6 +205,7 @@ class CourseDate extends SimpleORMap implements PrivacyObject
             $this->topics[] = $topic;
             return $this->storeRelations('topics');
         }
+        return false;
     }
 
     /**
diff --git a/lib/models/Courseware/Filesystem/PublicFolder.php b/lib/models/Courseware/Filesystem/PublicFolder.php
index 94a7b54a4b6..271c9294adb 100755
--- a/lib/models/Courseware/Filesystem/PublicFolder.php
+++ b/lib/models/Courseware/Filesystem/PublicFolder.php
@@ -163,6 +163,7 @@ class PublicFolder extends StandardFolder
      */
     public function setDataFromEditTemplate($request)
     {
+        return $this;
     }
 
     /**
@@ -204,6 +205,7 @@ class PublicFolder extends StandardFolder
      */
     public function deleteSubfolder($subfolderId)
     {
+        return false;
     }
 
     /**
diff --git a/lib/models/FileRef.php b/lib/models/FileRef.php
index a3f9a3a1b9f..a8f5da2997e 100644
--- a/lib/models/FileRef.php
+++ b/lib/models/FileRef.php
@@ -192,7 +192,7 @@ class FileRef extends SimpleORMap implements PrivacyObject, FeedbackRange
     /**
      * This method increments the download counter of the FileRef.
      *
-     * @return The number of rows of the file_refs table that have been altered.
+     * @return int The number of rows of the file_refs table that have been altered.
      */
     public function incrementDownloadCounter()
     {
@@ -204,6 +204,8 @@ class FileRef extends SimpleORMap implements PrivacyObject, FeedbackRange
                       WHERE {$where_query}";
             return DBManager::get()->exec($query);
         }
+
+        return 0;
     }
 
     /**
diff --git a/lib/models/Institute.class.php b/lib/models/Institute.class.php
index b25e3597e42..1ba4eb08a86 100644
--- a/lib/models/Institute.class.php
+++ b/lib/models/Institute.class.php
@@ -139,6 +139,7 @@ class Institute extends SimpleORMap implements Range
         if (Context::isInstitute()) {
             return Context::get();
         }
+        return null;
     }
 
     /**
diff --git a/lib/models/OERHostOERSI.php b/lib/models/OERHostOERSI.php
index 3ceb23c4eea..11a61fbd29f 100755
--- a/lib/models/OERHostOERSI.php
+++ b/lib/models/OERHostOERSI.php
@@ -77,7 +77,7 @@ class OERHostOERSI extends OERHost
      */
     public function pushDataToEndpoint($endpoint, $data)
     {
-        //nothing to do
+        return true;
     }
 
     /**
diff --git a/lib/models/PersonalNotifications.class.php b/lib/models/PersonalNotifications.class.php
index f403316caeb..dbdb266ecdd 100644
--- a/lib/models/PersonalNotifications.class.php
+++ b/lib/models/PersonalNotifications.class.php
@@ -176,7 +176,6 @@ class PersonalNotifications extends SimpleORMap
      * notification-list on top of its site.
      * @param string $notification_id : ID of the notification
      * @param string|null $user_id : ID of special user the notification should belong to or (default:) null for current user
-     * @return boolean : true on success, false if it failed.
      */
     public static function markAsRead($notification_id, $user_id = null)
     {
@@ -224,7 +223,6 @@ class PersonalNotifications extends SimpleORMap
      * notification-list on top of its site.
      * @param string $html_id : HTML ID attribute of the notification
      * @param string|null $user_id : ID of special user the notification should belong to or (default:) null for current user
-     * @return boolean : true on success, false if it failed.
      */
     public static function markAsReadByHTML($html_id, $user_id = null)
     {
diff --git a/lib/models/SeminarCycleDate.class.php b/lib/models/SeminarCycleDate.class.php
index 5f6c08ba34c..5fd6531dd9f 100644
--- a/lib/models/SeminarCycleDate.class.php
+++ b/lib/models/SeminarCycleDate.class.php
@@ -110,7 +110,7 @@ class SeminarCycleDate extends SimpleORMap
      * Returns the time fraction for a given field.
      *
      * @param String $field Time fraction field
-     * @return String containing the time fraction
+     * @return int the time fraction
      */
     protected function getTimeFraction($field)
     {
@@ -122,6 +122,8 @@ class SeminarCycleDate extends SimpleORMap
             list($end_hour, $end_minute) = explode(':', $this->end_time);
             return (int)$$field;
         }
+
+        throw new InvalidArgumentException("Invalid field {$field}");
     }
 
     /**
@@ -149,6 +151,8 @@ class SeminarCycleDate extends SimpleORMap
             $this->end_time = sprintf('%02u:%02u:00', $this->end_hour, $value);
             return $this->end_minute;
         }
+
+        throw new InvalidArgumentException("Invalid field {$field}");
     }
 
     /**
diff --git a/lib/models/SimpleORMap.class.php b/lib/models/SimpleORMap.class.php
index 92cdf423af7..3eeac13f643 100644
--- a/lib/models/SimpleORMap.class.php
+++ b/lib/models/SimpleORMap.class.php
@@ -1885,7 +1885,7 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
      * is instead invoked
      *
      * @param null|array|string $only_these
-     * @return number addition of all return values, false if none was called
+     * @return int|false number addition of all return values, false if none was called
      */
     protected function storeRelations($only_these = null)
     {
@@ -1955,9 +1955,9 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
                             WHERE ". join(" AND ", $where_query));
                 return true;
             }
-        } else {
-            return false;
         }
+
+        return false;
     }
 
     /**
diff --git a/lib/models/SimpleORMapCollection.class.php b/lib/models/SimpleORMapCollection.class.php
index 38914ddbb3b..94a52ecdfd8 100644
--- a/lib/models/SimpleORMapCollection.class.php
+++ b/lib/models/SimpleORMapCollection.class.php
@@ -149,7 +149,7 @@ class SimpleORMapCollection extends SimpleCollection
      * by calling the finder function
      *
      * @throws InvalidArgumentException
-     * @return number of records after refresh
+     * @return ?int number of records after refresh
      */
     public function refresh()
     {
@@ -164,6 +164,8 @@ class SimpleORMapCollection extends SimpleCollection
             $this->deleted->exchangeArray([]);
             return $this->last_count = $this->count();
         }
+
+        return null;
     }
 
     /**
diff --git a/lib/models/User.class.php b/lib/models/User.class.php
index fd95aa9070b..eb86a1e1433 100644
--- a/lib/models/User.class.php
+++ b/lib/models/User.class.php
@@ -209,13 +209,15 @@ class User extends AuthUserMd5 implements Range, PrivacyObject
     /**
      * Returns the currently authenticated user.
      *
-     * @return User User
+     * @return ?User User
      */
     public static function findCurrent()
     {
         if (is_object($GLOBALS['user'])) {
             return $GLOBALS['user']->getAuthenticatedUser();
         }
+
+        return null;
     }
 
     /**
@@ -241,7 +243,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject
      * Returns user object including user_info
      *
      * @param string $id
-     * @return User User
+     * @return ?User User
      */
     public static function findFull($id)
     {
@@ -253,6 +255,8 @@ class User extends AuthUserMd5 implements Range, PrivacyObject
         if ($data) {
             return self::buildExisting($data);
         }
+
+        return null;
     }
 
     /**
diff --git a/lib/modules/ConsultationModule.class.php b/lib/modules/ConsultationModule.class.php
index acb15b2be6d..ca5654d3725 100644
--- a/lib/modules/ConsultationModule.class.php
+++ b/lib/modules/ConsultationModule.class.php
@@ -57,9 +57,11 @@ class ConsultationModule extends CorePlugin implements StudipModule, SystemPlugi
      */
     public function getTabNavigation($course_id)
     {
-        if ($GLOBALS['user']->id !== 'nobody') {
-            return ['consultation' => new ConsultationNavigation(RangeFactory::find($course_id))];
+        if ($GLOBALS['user']->id === 'nobody') {
+            return [];
         }
+
+        return ['consultation' => new ConsultationNavigation(RangeFactory::find($course_id))];
     }
 
     /**
diff --git a/lib/modules/EvaluationsWidget.php b/lib/modules/EvaluationsWidget.php
index 4c902c7047e..bfe7cd81b23 100644
--- a/lib/modules/EvaluationsWidget.php
+++ b/lib/modules/EvaluationsWidget.php
@@ -38,25 +38,27 @@ class EvaluationsWidget extends CorePlugin implements PortalPlugin
      */
     public function getPortalTemplate()
     {
+        if (!Config::get()->VOTE_ENABLE) {
+            return null;
+        }
+
         // include and show votes and tests
-        if (Config::get()->VOTE_ENABLE) {
-            $controller = new AuthenticatedController(new StudipDispatcher());
-            $controller->suppress_empty_output = true;
+        $controller = new AuthenticatedController(new StudipDispatcher());
+        $controller->suppress_empty_output = true;
 
-            $response = $controller->relay('evaluation/display/studip')->body;
+        $response = $controller->relay('evaluation/display/studip')->body;
 
-            $controller->suppress_empty_output = (bool)$response;
-            $response .= $controller->relay('questionnaire/widget/start')->body;
+        $controller->suppress_empty_output = (bool)$response;
+        $response .= $controller->relay('questionnaire/widget/start')->body;
 
-            $template = $GLOBALS['template_factory']->open('shared/string');
-            $template->content = $response;
+        $template = $GLOBALS['template_factory']->open('shared/string');
+        $template->content = $response;
 
-            if ($GLOBALS['perm']->have_perm('root')) {
-                $navigation = new Navigation('', 'dispatch.php/questionnaire/overview');
-                $navigation->setImage(Icon::create('add', 'clickable', ["title" => _('Umfragen bearbeiten')]));
-                $template->icons = [$navigation];
-            }
-            return $template;
+        if ($GLOBALS['perm']->have_perm('root')) {
+            $navigation = new Navigation('', 'dispatch.php/questionnaire/overview');
+            $navigation->setImage(Icon::create('add', 'clickable', ["title" => _('Umfragen bearbeiten')]));
+            $template->icons = [$navigation];
         }
+        return $template;
     }
 }
diff --git a/lib/modules/FeedbackModule.class.php b/lib/modules/FeedbackModule.class.php
index 99be4e5b5b3..c369ea72a31 100644
--- a/lib/modules/FeedbackModule.class.php
+++ b/lib/modules/FeedbackModule.class.php
@@ -39,6 +39,8 @@ class FeedbackModule extends CorePlugin implements StudipModule, SystemPlugin
             $navigation->addSubNavigation('index', new Navigation(_('Ãœbersicht'), 'dispatch.php/course/feedback'));
             return ['feedback' => $navigation];
         }
+
+        return [];
     }
     /**
      * {@inheritdoc}
diff --git a/lib/modules/LtiToolModule.class.php b/lib/modules/LtiToolModule.class.php
index 3093615aa29..0383f115f64 100644
--- a/lib/modules/LtiToolModule.class.php
+++ b/lib/modules/LtiToolModule.class.php
@@ -55,6 +55,10 @@ class LtiToolModule extends CorePlugin implements StudipModule, SystemPlugin, Pr
      */
     public function getTabNavigation($course_id)
     {
+        if ($GLOBALS['user']->id === 'nobody') {
+            return [];
+        }
+
         $title = CourseConfig::get($course_id)->LTI_TOOL_TITLE;
         $grades = LtiData::countBySQL('course_id = ?', [$course_id]);
 
@@ -67,9 +71,7 @@ class LtiToolModule extends CorePlugin implements StudipModule, SystemPlugin, Pr
             $navigation->addSubNavigation('grades', new Navigation(_('Ergebnisse'), 'dispatch.php/course/lti/grades'));
         }
 
-        if ($GLOBALS['user']->id !== 'nobody') {
-            return ['lti' => $navigation];
-        }
+        return ['lti' => $navigation];
     }
 
     /**
diff --git a/lib/object.inc.php b/lib/object.inc.php
index c0c4e15653b..5f231da6de6 100644
--- a/lib/object.inc.php
+++ b/lib/object.inc.php
@@ -342,7 +342,7 @@ function object_return_views ($object_id)
 /**
  * converts a ouv type to an id
  * @param $type string former used type of visited objects or module (i.e. news, documents, wiki)
- * @return int
+ * @return ?int
  */
 function object_type_to_id($type)
 {
@@ -375,6 +375,7 @@ function object_type_to_id($type)
         }
     }
 
+    return null;
 }
 
 /**
diff --git a/lib/phplib/Seminar_Auth.class.php b/lib/phplib/Seminar_Auth.class.php
index ae4a0f0ca60..0411f75ae66 100644
--- a/lib/phplib/Seminar_Auth.class.php
+++ b/lib/phplib/Seminar_Auth.class.php
@@ -208,6 +208,8 @@ class Seminar_Auth
                 throw new RuntimeException("Error in auth handling: invalid state reached.");
                 break;
         }
+
+        return false;
     }
 
 
@@ -319,11 +321,10 @@ class Seminar_Auth
 
                     return $user->id;
                 }
-            } else {
-                return false;
             }
         }
-        // end of single sign on
+
+        return false;
     }
 
     /**
diff --git a/lib/phplib/Seminar_Perm.class.php b/lib/phplib/Seminar_Perm.class.php
index 736c1e3bb08..a116938f8a7 100644
--- a/lib/phplib/Seminar_Perm.class.php
+++ b/lib/phplib/Seminar_Perm.class.php
@@ -67,7 +67,7 @@ class Seminar_Perm
 
     /**
      * @param bool $user_id
-     * @return string
+     * @return string|null
      */
     public function get_perm($user_id = false)
     {
@@ -90,6 +90,8 @@ class Seminar_Perm
 
             return $this->studip_perms['studip'][$user_id] = $perms;
         }
+
+        return null;
     }
 
     /**
diff --git a/lib/phplib/Seminar_Register_Auth.class.php b/lib/phplib/Seminar_Register_Auth.class.php
index 4af44ef4707..dff388e6e93 100644
--- a/lib/phplib/Seminar_Register_Auth.class.php
+++ b/lib/phplib/Seminar_Register_Auth.class.php
@@ -151,13 +151,17 @@ class Seminar_Register_Auth extends Seminar_Auth
         $new_user->auth_plugin = 'standard';
         $new_user->store();
 
-        if ($new_user->user_id) {
-            self::sendValidationMail($new_user);
-            $this->auth['perm'] = $new_user->perms;
-            $this->auth['uname'] = $new_user->username;
-            $this->auth['auth_plugin'] = $new_user->auth_plugin;
-            return $new_user->user_id;
+        if (!$new_user->user_id) {
+            return false;
         }
+
+        self::sendValidationMail($new_user);
+
+        $this->auth['perm'] = $new_user->perms;
+        $this->auth['uname'] = $new_user->username;
+        $this->auth['auth_plugin'] = $new_user->auth_plugin;
+
+        return $new_user->user_id;
     }
 
     /**
diff --git a/lib/plugins/core/PortalPlugin.class.php b/lib/plugins/core/PortalPlugin.class.php
index ed157a8b9f3..dce5774f965 100644
--- a/lib/plugins/core/PortalPlugin.class.php
+++ b/lib/plugins/core/PortalPlugin.class.php
@@ -27,7 +27,7 @@ interface PortalPlugin
      *  admin_url    admin link for this plugin (if any)
      *  admin_title  title for admin link (default: Administration)
      *
-     * @return object   template object to render or NULL
+     * @return ?Flexi_Template template object to render or NULL
      */
     function getPortalTemplate();
 }
diff --git a/lib/raumzeit/CycleData.class.php b/lib/raumzeit/CycleData.class.php
index bcbdf284768..587e0bc7f5f 100644
--- a/lib/raumzeit/CycleData.class.php
+++ b/lib/raumzeit/CycleData.class.php
@@ -344,13 +344,11 @@ class CycleData
      *
      * @param int $filterStart
      * @param int $filterEnd
-     * @return array
+     * @return array|false
      */
     function getFreeTextPredominantRoom($filterStart = 0, $filterEnd = 0)
     {
-        if ($room = CycleDataDB::getFreeTextPredominantRoomDB($this->metadate_id, $filterStart, $filterEnd)) {
-            return $room;
-        }
+        return CycleDataDB::getFreeTextPredominantRoomDB($this->metadate_id, $filterStart, $filterEnd);
     }
 
     /**
diff --git a/lib/showNews.inc.php b/lib/showNews.inc.php
index 6c9ed38df4d..c00071357c2 100644
--- a/lib/showNews.inc.php
+++ b/lib/showNews.inc.php
@@ -150,8 +150,7 @@ function delete_news($delete_news_array)
  * generates proper text for confirmation question and removes range_id from news
  *
  *
- * @param $remove_array array with $news_id as key and array of range_ids as value
- * @param string $range_id
+ * @param array $remove_array with $news_id as key and array of range_ids as value
  * @return string text for confirmation question or empty string after removal
  */
 function remove_news($remove_array)
@@ -159,7 +158,7 @@ function remove_news($remove_array)
     $confirmed = false;
     $question_text = [];
     if (!is_array($remove_array)) {
-        return false;
+        return '';
     }
     if (Request::submitted('yes') && Request::isPost()) {
         CSRFProtection::verifySecurityToken();
@@ -227,6 +226,8 @@ function remove_news($remove_array)
     if (count($question_text) == 1) {
         return _('Wollen Sie diese Aktion jetzt ausführen?') . "\n" . implode($question_text);
     }
+
+    return '';
 }
 
 /**
-- 
GitLab