diff --git a/src/services/FileService.php b/src/services/FileService.php
index <HASH>..<HASH> 100644
--- a/src/services/FileService.php
+++ b/src/services/FileService.php
@@ -63,7 +63,7 @@ class FileService
     protected function getFileByPath($filePath)
     {
         $file = $this->storage->getFiles()->getFileByName($filePath);
-        return new File($file);
+        return $file === null ? null : new File($file);
     }
 
     /**
diff --git a/src/storage/storage/ImagesStorage.php b/src/storage/storage/ImagesStorage.php
index <HASH>..<HASH> 100644
--- a/src/storage/storage/ImagesStorage.php
+++ b/src/storage/storage/ImagesStorage.php
@@ -103,7 +103,7 @@ class ImagesStorage extends AbstractStorage
     /**
      * @param $filename
      *
-     * @return null
+     * @return \stdClass|null
      */
     public function getImageByName($filename)
     {
Minor refactor to fix two bugs