diff --git a/apps/files_trashbin/lib/Trash/TrashItem.php b/apps/files_trashbin/lib/Trash/TrashItem.php index 2ae999a20698b..70d5164747f0b 100644 --- a/apps/files_trashbin/lib/Trash/TrashItem.php +++ b/apps/files_trashbin/lib/Trash/TrashItem.php @@ -70,7 +70,7 @@ public function getPath() { 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 ab5bae316f455..c558ec7721e8f 100644 --- a/lib/private/Files/Cache/CacheEntry.php +++ b/lib/private/Files/Cache/CacheEntry.php @@ -65,8 +65,8 @@ public function getName() { } - 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 0679dc1ae7254..967d404b8a4f0 100644 --- a/lib/private/Files/FileInfo.php +++ b/lib/private/Files/FileInfo.php @@ -133,11 +133,8 @@ public function getId() { 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 37b1efa0fad52..ceadc4cad1e9c 100644 --- a/lib/private/Files/Node/LazyFolder.php +++ b/lib/private/Files/Node/LazyFolder.php @@ -314,10 +314,7 @@ public function getUserFolder($userId) { 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 5b8f556030c63..fd8d84883d964 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -339,7 +339,7 @@ public function isShared() { 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 66ec2e6c0403c..7fb375b941adc 100644 --- a/lib/private/Files/Node/NonExistingFile.php +++ b/lib/private/Files/Node/NonExistingFile.php @@ -122,7 +122,7 @@ public function putContent($data) { 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 28e673071fd4c..790c972b51bfc 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 @@ * 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 @@ public function getName(); /** * 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 d0aceeaba3781..67b7a7d0d2ad7 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 @@ * * @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 @@ public function putContent($data); /** * 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 f9957f580e8e8..95419d6354ac4 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 @@ * * @since 7.0.0 */ +#[Consumable(since: '7.0.0')] interface FileInfo { /** * @since 7.0.0 @@ -103,10 +105,9 @@ public function getPath(); /** * 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'