diff --git a/app/controllers/course/elearning.php b/app/controllers/course/elearning.php
index a8a7626bed8003277fad8c49699072e066327092..6e67b64a65318429b91aa81c55d9d00598e980e0 100644
--- a/app/controllers/course/elearning.php
+++ b/app/controllers/course/elearning.php
@@ -57,7 +57,10 @@ class Course_ElearningController extends AuthenticatedController
         if (!isset($GLOBALS['ELEARNING_INTERFACE_MODULES'][$this->cms_select])) {
             unset($this->cms_select);
         }
-        if ($this->seminar_id != $_SESSION['elearning_open_close']["id"]) {
+        if (
+            isset($_SESSION['elearning_open_close']['id'])
+            && $this->seminar_id !== $_SESSION['elearning_open_close']['id']
+        ) {
             unset($_SESSION['cache_data']);
             unset($_SESSION['elearning_open_close']);
         }
diff --git a/app/controllers/course/wizard.php b/app/controllers/course/wizard.php
index a348b9f11c366039a9af9b88132b3f4d1abca4e0..c3aa0f1320e2bf4a5de0a849d3975f1032d887a6 100644
--- a/app/controllers/course/wizard.php
+++ b/app/controllers/course/wizard.php
@@ -118,7 +118,7 @@ class Course_WizardController extends AuthenticatedController
             $values[$iterator->key()] = $iterator->current();
             $iterator->next();
         }
-        if ($this->steps[$step_number]['classname']) {
+        if (!empty($this->steps[$step_number]['classname'])) {
             $this->setStepValues($this->steps[$step_number]['classname'], $values);
         }
         // Back or forward button clicked -> set next step accordingly.
diff --git a/app/controllers/new_password.php b/app/controllers/new_password.php
index 5132c4804f2bb4b27d120e09054dcf3847a9f6b7..525d73b66232e56a9becba8f6d85b6c0f0e9552c 100644
--- a/app/controllers/new_password.php
+++ b/app/controllers/new_password.php
@@ -111,6 +111,7 @@ class NewPasswordController extends StudipController
             $password = Request::get('new_password');
             $confirm  = Request::get('new_password_confirm');
 
+            $errors = [];
             if (!$validator->ValidatePassword($password)) {
                 $errors[] = _('Das Passwort ist zu kurz. Es sollte mindestens 8 Zeichen lang sein.');
             } else if ($password !== $confirm) {
diff --git a/lib/classes/coursewizardsteps/BasicDataWizardStep.php b/lib/classes/coursewizardsteps/BasicDataWizardStep.php
index ce3b57f0752b81262c3d12bbbc62f823edd78d3c..100786b057392784af39aeccd231360bebdb393c 100644
--- a/lib/classes/coursewizardsteps/BasicDataWizardStep.php
+++ b/lib/classes/coursewizardsteps/BasicDataWizardStep.php
@@ -344,13 +344,13 @@ class BasicDataWizardStep implements CourseWizardStep
         if (!trim($values['name'])) {
             $errors[] = _('Bitte geben Sie den Namen der Veranstaltung an.');
         }
-        if ($values['number'] != '') {
+        if (!empty($values['number'])) {
             $course_number_format = Config::get()->COURSE_NUMBER_FORMAT;
             if ($course_number_format && !preg_match('/^' . $course_number_format . '$/', $values['number'])) {
                 $errors[] = _('Die Veranstaltungsnummer hat ein ungültiges Format.');
             }
         }
-        if (!$values['lecturers']) {
+        if (empty($values['lecturers'])) {
             $errors[] = sprintf(
                 _('Bitte tragen Sie mindestens eine Person als %s ein.'),
                 htmlReady(get_title_for_status('dozent', 1, $values['coursetype']))
@@ -411,7 +411,7 @@ class BasicDataWizardStep implements CourseWizardStep
 
         $course->status = $values['coursetype'];
         $course->name = new I18NString($values['name'], $values['name_i18n'] ?? []);
-        $course->veranstaltungsnummer = $values['number'];
+        $course->veranstaltungsnummer = $values['number'] ?? null;
         $course->beschreibung = new I18NString($values['description'], $values['description_i18n'] ?? []);
         $course->start_semester = Semester::findByTimestamp($values['start_time']);
         $course->institut_id = $values['institute'];
diff --git a/lib/elearning/ELearningUtils.class.php b/lib/elearning/ELearningUtils.class.php
index 30c40c401a2e898d5faeac921f3ae40044a98fd8..d027e37210263936a4690a88916a5782dacf1639 100644
--- a/lib/elearning/ELearningUtils.class.php
+++ b/lib/elearning/ELearningUtils.class.php
@@ -472,6 +472,7 @@ class ELearningUtils
                           FROM object_contentmodules
                           WHERE module_type = 'crs' AND object_id = " . $db->quote($sem_id))
                         ->fetchAll(PDO::FETCH_ASSOC);
+        $courses = [];
         foreach ($rs as $row) {
             $courses[$row['system_type']] = $row['module_id'];
         }
@@ -479,23 +480,26 @@ class ELearningUtils
         $connected_courses = [
             'courses' => [],
         ];
-        if (is_array($courses))
-            foreach ($courses as $system_type => $crs_id)
+        if (is_array($courses)) {
+            foreach ($courses as $system_type => $crs_id) {
                 if (self::isCMSActive($system_type)) {
                     self::loadClass($system_type);
                     $connected_courses['courses'][$system_type] = [
-                        'url' => URLHelper::getLink($connected_cms[$system_type]->link->cms_link . '?client_id=' . $connected_cms[$system_type]->getClientId() . '&cms_select=' . $system_type . '&ref_id=' . $crs_id . '&type=crs&target=start'),
-                        'cms_name' => $connected_cms[$system_type]->getName()];
+                        'url'      => URLHelper::getLink($connected_cms[$system_type]->link->cms_link . '?client_id=' . $connected_cms[$system_type]->getClientId() . '&cms_select=' . $system_type . '&ref_id=' . $crs_id . '&type=crs&target=start'),
+                        'cms_name' => $connected_cms[$system_type]->getName()
+                    ];
                     // gegebenenfalls zugeordnete Module aktualisieren
                     if (Request::option('update')) {
                         if ((method_exists($connected_cms[$system_type], "updateConnections"))) {
-                            $connected_cms[$system_type]->updateConnections( $crs_id );
+                            $connected_cms[$system_type]->updateConnections($crs_id);
                         }
                     }
                     if (method_exists($connected_cms[$system_type]->permissions, 'CheckUserPermissions')) {
                         $connected_cms[$system_type]->permissions->CheckUserPermissions($crs_id);
                     }
                 }
+            }
+        }
 
         if ($connected_courses['courses']) {
             if (count($connected_courses['courses']) > 1) {
diff --git a/lib/filesystem/PublicFolder.php b/lib/filesystem/PublicFolder.php
index 15fdf34cd28831e5a58704ce77070d7c62618273..6b06ac905a42ce67410f49e39d64207691f6d8cc 100644
--- a/lib/filesystem/PublicFolder.php
+++ b/lib/filesystem/PublicFolder.php
@@ -60,7 +60,7 @@ class PublicFolder extends StandardFolder
     public function __get($attribute)
     {
         if ($attribute === 'viewable') {
-            return $this->folderdata['data_content']['viewable'];
+            return !empty($this->folderdata['data_content']['viewable']);
         }
         return $this->folderdata[$attribute];
     }
diff --git a/lib/models/Course.class.php b/lib/models/Course.class.php
index 2d485490fc2481d1d7c3f0d6a2e4b1d74038b0db..999b797fe197f9ec711b1b91dd2bae995236ee86 100644
--- a/lib/models/Course.class.php
+++ b/lib/models/Course.class.php
@@ -317,7 +317,7 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe
     {
         $end_semester = $this->semesters->last();
         $start_semester = $this->semesters->first();
-        if ($start_semester->id === $semester->id) {
+        if ($start_semester && $start_semester->id === $semester->id) {
             return;
         }
         if ($end_semester) {
@@ -345,7 +345,9 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe
     {
         $end_semester = $this->semesters->last();
         $start_semester = $this->semesters->first();
-        if ((is_null($end_semester) && is_null($semester)) || ($end_semester->id === $semester->id)) {
+        if (
+            (is_null($end_semester) && is_null($semester))
+            || ($end_semester && $semester && $end_semester->id === $semester->id)) {
             return;
         }
         if ($start_semester) {
diff --git a/lib/models/OERMaterial.php b/lib/models/OERMaterial.php
index ea36035d78ea3a45797814566c3dd0fdae204be1..f0e101d94df3d5d9aaba0794cfbe3206b314c195 100644
--- a/lib/models/OERMaterial.php
+++ b/lib/models/OERMaterial.php
@@ -390,8 +390,10 @@ class OERMaterial extends SimpleORMap
         }
         $url = $this->getDownloadUrl();
         $headers = get_headers($url, true, get_default_http_stream_context($url));
-        if ($headers['Content-Disposition']
-            && substr($headers['Content-Disposition'], 0, strlen('attachment')) === 'attachment') {
+        if (
+            !empty($headers['Content-Disposition'])
+            && substr($headers['Content-Disposition'], 0, strlen('attachment')) === 'attachment'
+        ) {
             //in this case the server forces to download the document and we cannot display it in an iframe:
             return false;
         }
diff --git a/lib/models/SimpleCollection.class.php b/lib/models/SimpleCollection.class.php
index 11dd29653017b3ce74aa068e5862ac18c8918777..42285998aadcef9f8bf171b058b3e9f67aa69b2a 100644
--- a/lib/models/SimpleCollection.class.php
+++ b/lib/models/SimpleCollection.class.php
@@ -592,7 +592,7 @@ class SimpleCollection extends StudipArrayObject
     public function val($key)
     {
         $first = $this->first();
-        return $first[$key] ?: null;
+        return $first[$key] ?? null;
     }
 
     /**
diff --git a/lib/visual.inc.php b/lib/visual.inc.php
index a4bb96eb070ba0cc41172ae4d01873d097853839..30b67246c4abc23066e0b6a0e483537d2c7158eb 100644
--- a/lib/visual.inc.php
+++ b/lib/visual.inc.php
@@ -399,14 +399,13 @@ function symbol ($text = '')
 function mila ($titel, $size = 60) {
     global $auth;
 
-    if ($auth->auth["jscript"] AND $size == 60) {
+    if (!empty($auth->auth['jscript']) && $size == 60) {
         //hier wird die maximale Laenge berechnet, nach der Abgeschnitten wird (JS dynamisch)
-        if (mb_strlen ($titel) >$auth->auth["xres"] / 13)
-            $titel=mb_substr($titel, 0, $auth->auth["xres"] / 13)."... ";
-    }
-    else {
-        if (mb_strlen ($titel) >$size)
-            $titel=mb_substr($titel, 0, $size)."... ";
+        if (mb_strlen($titel) > $auth->auth['xres'] / 13) {
+            $titel = mb_substr($titel, 0, $auth->auth['xres'] / 13) . '... ';
+        }
+    } elseif (mb_strlen ($titel) >$size) {
+        $titel = mb_substr($titel, 0, $size) . '... ';
     }
     return $titel;
 }