diff --git a/lib/filesystem/CourseDateFolder.php b/lib/filesystem/CourseDateFolder.php
index 0973a1f516ae14e319d5eccc30d5b81ee0412141..1c42799a7b8d06a9abe50d71c56ca1b46d92b56c 100644
--- a/lib/filesystem/CourseDateFolder.php
+++ b/lib/filesystem/CourseDateFolder.php
@@ -40,6 +40,8 @@ class CourseDateFolder extends PermissionEnabledFolder implements FolderType
             return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id)
                 && CourseDate::countBySql("range_id = ?" , [$course->id]);
         }
+
+        return false;
     }
 
     public function __construct($folderdata = null)
@@ -56,10 +58,7 @@ class CourseDateFolder extends PermissionEnabledFolder implements FolderType
         );
     }
 
-    /**
-     * @return CourseDate
-     */
-    public function getDate()
+    public function getDate(): ?CourseDate
     {
         if (isset($this->folderdata['data_content']['termin_id'])) {
             if ($this->date === null) {
@@ -72,6 +71,8 @@ class CourseDateFolder extends PermissionEnabledFolder implements FolderType
             }
             return $this->date;
         }
+
+        return null;
     }
 
     /**
diff --git a/lib/filesystem/CourseGroupFolder.php b/lib/filesystem/CourseGroupFolder.php
index e71da7e3a46930351614a61d09dcd7185d6b1e35..81867f6649142a56474db9f2a47a2d2449f190ce 100644
--- a/lib/filesystem/CourseGroupFolder.php
+++ b/lib/filesystem/CourseGroupFolder.php
@@ -40,12 +40,14 @@ class CourseGroupFolder extends StandardFolder
         if ($course && !$course->isNew()) {
             return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id) && Statusgruppen::countBySql("range_id = ?" , [$course->id]);
         }
+
+        return false;
     }
 
     /**
      * This method check the permission (global and if he is in the group) for a given user
      *
-     * @param $user_id The User-ID
+     * @param string $user_id The User-ID
      * @return bool True if user have permission, False otherwise
      */
     public function checkPermission($user_id)
@@ -60,7 +62,7 @@ class CourseGroupFolder extends StandardFolder
     /**
      * Check if this GroupFolder instance is visible for this user or not.
      *
-     * @param user_id The User-ID
+     * @param string $user_id The User-ID
      * @return bool True, if the user is in this group or is the lecturer, false otherwise
      */
     public function isVisible($user_id)
@@ -71,7 +73,7 @@ class CourseGroupFolder extends StandardFolder
     /**
      * Check if this GroupFolder instance is readable for this user or not.
      *
-     * @param user_id The User-ID
+     * @param string $user_id The User-ID
      * @return bool True, if the user is in this group or is the lecturer, false otherwise
      */
     public function isReadable($user_id)
@@ -82,7 +84,7 @@ class CourseGroupFolder extends StandardFolder
     /**
      * Check if this GroupFolder instance is writable for this user or not.
      *
-     * @param user_id The User-ID
+     * @param string $user_id The User-ID
      * @return bool True, if the user is in this group or is the lecturer, false otherwise
      */
     public function isWritable($user_id)
diff --git a/lib/filesystem/CoursePublicFolder.php b/lib/filesystem/CoursePublicFolder.php
index a55539dea7741c0c95d48dc2fd1244efa45560d4..a86b251744f72e4cc0d703be0603cff594dcb241 100644
--- a/lib/filesystem/CoursePublicFolder.php
+++ b/lib/filesystem/CoursePublicFolder.php
@@ -38,6 +38,7 @@ class CoursePublicFolder extends StandardFolder
         if ($course && !$course->isNew()) {
             return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id);
         }
+        return false;
     }
 
     public function getIcon($role = Icon::DEFAULT_ROLE)
diff --git a/lib/filesystem/CourseTopicFolder.php b/lib/filesystem/CourseTopicFolder.php
index f49ea8801f7f0f261dc6045b9485f76e4d11f722..3d358366e7691bdbca61607ca9417ee7035c285c 100644
--- a/lib/filesystem/CourseTopicFolder.php
+++ b/lib/filesystem/CourseTopicFolder.php
@@ -31,6 +31,7 @@ class CourseTopicFolder extends PermissionEnabledFolder implements FolderType
         if ($course && !$course->isNew()) {
             return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id) && CourseTopic::countBySql("seminar_id = ?" , [$course->id]);
         }
+        return false;
     }
 
     public function __construct($folderdata = null)
@@ -47,10 +48,7 @@ class CourseTopicFolder extends PermissionEnabledFolder implements FolderType
         );
     }
 
-    /**
-     * @return CourseTopic
-     */
-    public function getTopic()
+    public function getTopic(): ?CourseTopic
     {
         if (isset($this->folderdata['data_content']['topic_id'])) {
             if ($this->topic === null) {
@@ -64,13 +62,15 @@ class CourseTopicFolder extends PermissionEnabledFolder implements FolderType
             }
             return $this->topic;
         }
+
+        return null;
     }
 
     /**
      * @param CourseTopic $topic
      * @return CourseTopic
      */
-    public function setTopic(CourseTopic $topic)
+    public function setTopic(CourseTopic $topic): ?CourseTopic
     {
         $this->topic = $topic;
         $this->folderdata['data_content']['topic_id'] = $this->topic->id;
diff --git a/lib/filesystem/FileManager.php b/lib/filesystem/FileManager.php
index b5c96bbac431ac17c463be866dee7e0d435f268d..48d09ab1f19b3fa1e2de4e82b868bc449589496f 100644
--- a/lib/filesystem/FileManager.php
+++ b/lib/filesystem/FileManager.php
@@ -742,7 +742,7 @@ class FileManager
                     return [_('Datei konnte nicht gespeichert werden.')];
                 }
             } else {
-                return $error;
+                return [$error];
             }
 
         } else {
@@ -1081,7 +1081,7 @@ class FileManager
                     $file_ref = FileRef::build((array) $file_ref, false);
                     $file_ref->setFolderType('foldertype', $source_folder);
                 }
-                $result = self::moveFileRef($file_ref, $new_folder, $user);
+                $result = self::moveFile($file_ref->getFileType(), $new_folder, $user);
                 if (!$result instanceof FileRef) {
                     //error
                     return $result;
diff --git a/lib/filesystem/FileType.php b/lib/filesystem/FileType.php
index 003ee856a9ac46120dd80214953526f61860a1b3..60bfa441eab99b36d475d4a751f73ce503b674d6 100644
--- a/lib/filesystem/FileType.php
+++ b/lib/filesystem/FileType.php
@@ -2,6 +2,14 @@
 
 interface FileType
 {
+    /**
+     * StandardFile constructor.
+     * @param $fileref
+     * @param null $file : (optional) Is set if fileref and file are both new and not connected with
+     *                     each other in the database.
+     */
+    public function __construct($fileref, $file = null);
+
     /**
      * Returns the name of the icon shape that shall be used with the FileType implementation.
      *
diff --git a/lib/filesystem/HomeworkFolder.php b/lib/filesystem/HomeworkFolder.php
index 8c811f3e4616a565d1fce90ea4dab9356a407d70..70447fb6cf6166e85e598733af672d8d1465c53c 100644
--- a/lib/filesystem/HomeworkFolder.php
+++ b/lib/filesystem/HomeworkFolder.php
@@ -37,6 +37,7 @@ class HomeworkFolder extends PermissionEnabledFolder
         if ($course && !$course->isNew()) {
             return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id);
         }
+        return false;
     }
 
     public function __construct($folderdata = null)
diff --git a/lib/filesystem/InboxOutboxFolder.php b/lib/filesystem/InboxOutboxFolder.php
index ff75988753d9a09c89d7a42eaad479e8478b1c81..9386be426da44a418c630d6d9f518c01862dbe0c 100644
--- a/lib/filesystem/InboxOutboxFolder.php
+++ b/lib/filesystem/InboxOutboxFolder.php
@@ -175,9 +175,10 @@ class InboxOutboxFolder implements FolderType
             _('InboxOutbox-Ordner können nicht bearbeitet werden!')
         );
     }
+
     public function store()
     {
-
+        return false;
     }
 
     /**
diff --git a/lib/filesystem/MessageFolder.php b/lib/filesystem/MessageFolder.php
index 34c99cf128a6483e27cbcc6d376534d979b77d76..2e5c3afbc25566cbe3ad62ed4a4479ab73ec8301 100644
--- a/lib/filesystem/MessageFolder.php
+++ b/lib/filesystem/MessageFolder.php
@@ -236,6 +236,7 @@ class MessageFolder extends StandardFolder implements FolderType
      */
     public function setDataFromEditTemplate($request)
     {
+        return MessageBox::error('Not applicable for message folders');
     }
 
     /**
@@ -307,6 +308,7 @@ class MessageFolder extends StandardFolder implements FolderType
      */
     public function deleteSubfolder($subfolder_id)
     {
+        return false;
     }
 
     /**
diff --git a/lib/filesystem/StandardFile.php b/lib/filesystem/StandardFile.php
index 208e447f35a596f1108bbffa2dbb92ae6ab15284..3fe3672e723691029c7502d9157aa713da393219 100644
--- a/lib/filesystem/StandardFile.php
+++ b/lib/filesystem/StandardFile.php
@@ -30,7 +30,7 @@ class StandardFile implements FileType, ArrayAccess
      * @param null|string $user_id : the id of the user that should own the new file
      * @return FileType|array : FileType (of called class) on success or an array with errors if an error occurred.
      */
-    static public function create($data, $user_id = null)
+    public static function create($data, $user_id = null)
     {
         $errors = [];
         $user_id || $user_id = $GLOBALS['user']->id;
diff --git a/lib/filesystem/StandardFolder.php b/lib/filesystem/StandardFolder.php
index 269f64a017fe8e68af1b3336d1ba2080aa804ed3..a34ca4ae820d1037c260a901bb8d448367875463 100644
--- a/lib/filesystem/StandardFolder.php
+++ b/lib/filesystem/StandardFolder.php
@@ -202,7 +202,7 @@ class StandardFolder implements FolderType
     }
 
     /**
-     * @param Request $request
+     * @param array $request
      * @return FolderType|MessageBox
      */
     public function setDataFromEditTemplate($request)
@@ -357,6 +357,8 @@ class StandardFolder implements FolderType
         if ($file_ref) {
             return $file_ref->delete();
         }
+
+        return 0;
     }
 
 
diff --git a/lib/filesystem/TimedFolder.php b/lib/filesystem/TimedFolder.php
index aa08df3819be7bcefbcd8088bb00c8bf9469836d..f2c66dbf3e145b63e3d217b532693441d6eb6a34 100644
--- a/lib/filesystem/TimedFolder.php
+++ b/lib/filesystem/TimedFolder.php
@@ -42,6 +42,7 @@ class TimedFolder extends PermissionEnabledFolder
         if ($course && !$course->isNew()) {
             return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id);
         }
+        return false;
     }
 
     /**
diff --git a/lib/filesystem/UnknownFileType.php b/lib/filesystem/UnknownFileType.php
index 7d5a0bcfaeb39d809260b5a1ba74dcf03d4f736c..c8df875fe09e46cbf1dd9274868e212aeab2cd3a 100644
--- a/lib/filesystem/UnknownFileType.php
+++ b/lib/filesystem/UnknownFileType.php
@@ -20,7 +20,7 @@ class UnknownFileType implements FileType, ArrayAccess
      */
     protected $fileref = null;
 
-    public function __construct($fileref = null)
+    public function __construct($fileref = null, $file = null)
     {
         $this->fileref = $fileref;
     }
@@ -151,6 +151,7 @@ class UnknownFileType implements FileType, ArrayAccess
      */
     public function getPath(): string
     {
+        return '';
     }
 
     /**
@@ -210,6 +211,7 @@ class UnknownFileType implements FileType, ArrayAccess
      */
     public function delete()
     {
+        return 0;
     }
 
     /**
@@ -272,6 +274,7 @@ class UnknownFileType implements FileType, ArrayAccess
      */
     public function getAdditionalColumnOrderWeigh($column_index)
     {
+        return 0;
     }
 
     /**
@@ -279,5 +282,6 @@ class UnknownFileType implements FileType, ArrayAccess
      */
     public function getInfoTemplate(bool $include_downloadable_infos = false)
     {
+        return '';
     }
 }
diff --git a/lib/filesystem/UnknownFolderType.php b/lib/filesystem/UnknownFolderType.php
index 46907180e09fc50fdc936ccb21ecfd02bc866ac9..a7ba5f1dd0372ec2c92720c4251d67b3916440bf 100644
--- a/lib/filesystem/UnknownFolderType.php
+++ b/lib/filesystem/UnknownFolderType.php
@@ -136,7 +136,7 @@ class UnknownFolderType implements FolderType
      */
     public function getDescriptionTemplate()
     {
-
+        return '';
     }
 
 
@@ -145,7 +145,7 @@ class UnknownFolderType implements FolderType
      */
     public function getEditTemplate()
     {
-
+        return '';
     }
 
     /**
@@ -153,7 +153,7 @@ class UnknownFolderType implements FolderType
      */
     public function setDataFromEditTemplate($request)
     {
-
+        return MessageBox::error('Not applicable for unknown folder type');
     }
 
     /**
diff --git a/lib/filesystem/VirtualFolderType.php b/lib/filesystem/VirtualFolderType.php
index ec2d773802ce74a0738eae9e725bcbdbc285a054..36ad3fed062f513e060a7eff074f9322ea7e5d21 100644
--- a/lib/filesystem/VirtualFolderType.php
+++ b/lib/filesystem/VirtualFolderType.php
@@ -165,6 +165,7 @@ class VirtualFolderType implements FolderType
      */
     public function setDataFromEditTemplate($request)
     {
+        return MessageBox::error('Not applicable for virtual folder type');
     }
 
     /**
@@ -257,11 +258,9 @@ class VirtualFolderType implements FolderType
         return true;
     }
 
-    /**
-     *
-     */
     public function store()
     {
+        return 0;
     }
 
     /**