diff --git a/apps/files_trashbin/lib/Trash/TrashItem.php b/apps/files_trashbin/lib/Trash/TrashItem.php index 2ae999a2069..70d5164747f 100644 --- a/apps/files_trashbin/lib/Trash/TrashItem.php +++ b/apps/files_trashbin/lib/Trash/TrashItem.php @@ -70,7 +70,7 @@ class TrashItem implements ITrashItem { return $this->fileInfo->getPath(); } - public function getMimetype() { + public function getMimetype(): string { return $this->fileInfo->getMimetype(); } diff --git a/lib/private/Files/Cache/CacheEntry.php b/lib/private/Files/Cache/CacheEntry.php index ab5bae316f4..c558ec7721e 100644 --- a/lib/private/Files/Cache/CacheEntry.php +++ b/lib/private/Files/Cache/CacheEntry.php @@ -65,8 +65,8 @@ class CacheEntry implements ICacheEntry { } - public function getMimeType() { - return $this->data['mimetype']; + public function getMimeType(): string { + return $this->data['mimetype'] ?? 'application/octet-stream'; } diff --git a/lib/private/Files/FileInfo.php b/lib/private/Files/FileInfo.php index 0679dc1ae72..967d404b8a4 100644 --- a/lib/private/Files/FileInfo.php +++ b/lib/private/Files/FileInfo.php @@ -133,11 +133,8 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { return isset($this->data['fileid']) ? (int)$this->data['fileid'] : null; } - /** - * @return string - */ - public function getMimetype() { - return $this->data['mimetype']; + public function getMimetype(): string { + return $this->data['mimetype'] ?? 'application/octet-stream'; } /** diff --git a/lib/private/Files/Node/LazyFolder.php b/lib/private/Files/Node/LazyFolder.php index 37b1efa0fad..ceadc4cad1e 100644 --- a/lib/private/Files/Node/LazyFolder.php +++ b/lib/private/Files/Node/LazyFolder.php @@ -314,10 +314,7 @@ class LazyFolder implements Folder { return $this->__call(__FUNCTION__, func_get_args()); } - /** - * @inheritDoc - */ - public function getMimetype() { + public function getMimetype(): string { if (isset($this->data['mimetype'])) { return $this->data['mimetype']; } diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php index 5dbdc4054bf..fa0c7eea767 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -339,7 +339,7 @@ class Node implements INode { return $this->getFileInfo(false)->isShared(); } - public function getMimeType() { + public function getMimeType(): string { return $this->getFileInfo(false)->getMimetype(); } diff --git a/lib/private/Files/Node/NonExistingFile.php b/lib/private/Files/Node/NonExistingFile.php index 66ec2e6c040..7fb375b941a 100644 --- a/lib/private/Files/Node/NonExistingFile.php +++ b/lib/private/Files/Node/NonExistingFile.php @@ -122,7 +122,7 @@ class NonExistingFile extends File { throw new NotFoundException(); } - public function getMimeType() { + public function getMimeType(): string { if ($this->fileInfo) { return parent::getMimeType(); } else { diff --git a/lib/public/Files/Cache/ICacheEntry.php b/lib/public/Files/Cache/ICacheEntry.php index 28e673071fd..790c972b51b 100644 --- a/lib/public/Files/Cache/ICacheEntry.php +++ b/lib/public/Files/Cache/ICacheEntry.php @@ -8,6 +8,7 @@ namespace OCP\Files\Cache; use ArrayAccess; +use OCP\AppFramework\Attribute\Consumable; /** * meta data for a file or folder @@ -19,6 +20,7 @@ use ArrayAccess; * implemented it in the private implementation. Hence php would allow using the * object as array, while strictly speaking it didn't support this. */ +#[Consumable(since: '9.0.0')] interface ICacheEntry extends ArrayAccess { /** * @since 9.0.0 @@ -60,10 +62,9 @@ interface ICacheEntry extends ArrayAccess { /** * Get the full mimetype * - * @return string * @since 9.0.0 */ - public function getMimeType(); + public function getMimeType(): string; /** * Get the first part of the mimetype diff --git a/lib/public/Files/File.php b/lib/public/Files/File.php index d0aceeaba37..67b7a7d0d2a 100644 --- a/lib/public/Files/File.php +++ b/lib/public/Files/File.php @@ -10,6 +10,7 @@ namespace OCP\Files; +use OCP\AppFramework\Attribute\Consumable; use OCP\Lock\LockedException; /** @@ -17,6 +18,7 @@ use OCP\Lock\LockedException; * * @since 6.0.0 */ +#[Consumable(since: '6.0.0')] interface File extends Node { /** * Get the content of the file as string @@ -43,10 +45,9 @@ interface File extends Node { /** * Get the mimetype of the file * - * @return string * @since 6.0.0 */ - public function getMimeType(); + public function getMimeType(): string; /** * Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen diff --git a/lib/public/Files/FileInfo.php b/lib/public/Files/FileInfo.php index f9957f580e8..95419d6354a 100644 --- a/lib/public/Files/FileInfo.php +++ b/lib/public/Files/FileInfo.php @@ -7,6 +7,7 @@ */ namespace OCP\Files; +use OCP\AppFramework\Attribute\Consumable; use OCP\Files\Storage\IStorage; /** @@ -14,6 +15,7 @@ use OCP\Files\Storage\IStorage; * * @since 7.0.0 */ +#[Consumable(since: '7.0.0')] interface FileInfo { /** * @since 7.0.0 @@ -103,10 +105,9 @@ interface FileInfo { /** * Get the full mimetype of the file or folder i.e. 'image/png' * - * @return string * @since 7.0.0 */ - public function getMimetype(); + public function getMimetype(): string; /** * Get the first part of the mimetype of the file or folder i.e. 'image'