From 7f264e380c3fd53f80564b9743457d5cbf9e1e9f Mon Sep 17 00:00:00 2001 From: Thorsten Rinne Date: Wed, 6 Nov 2024 13:59:47 +0100 Subject: [PATCH] fix: corrected PHP 8.4 deprecation warning --- phpmyfaq/src/phpMyFAQ/Attachment/File.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/phpmyfaq/src/phpMyFAQ/Attachment/File.php b/phpmyfaq/src/phpMyFAQ/Attachment/File.php index 777e3acad0..ce8f04f737 100644 --- a/phpmyfaq/src/phpMyFAQ/Attachment/File.php +++ b/phpmyfaq/src/phpMyFAQ/Attachment/File.php @@ -84,16 +84,15 @@ public function isStorageOk(): bool } /** - * Save current attachment to the appropriate storage. The - * filepath given will be processed and moved to appropriate - * location. + * Save current attachment to the appropriate storage. + * The filepath given will be processed and moved to the appropriate location. * * @param string $filePath full path to the attachment file * @param string|null $filename filename to force * @throws FileException|AttachmentException * @todo rollback if something went wrong */ - public function save($filePath, string $filename = null): bool + public function save($filePath, ?string $filename = null): bool { $success = false; @@ -106,7 +105,7 @@ public function save($filePath, string $filename = null): bool $targetFile = $this->buildFilePath(); - if (null !== $this->id && $this->createSubDirs($targetFile)) { + if ($this->createSubDirs($targetFile)) { // Doing this check, we're sure not to unnecessarily // overwrite existing unencrypted file duplicates. if (!$this->linkedRecords()) { @@ -134,7 +133,7 @@ public function save($filePath, string $filename = null): bool /** * Delete attachment. * - * @throws FileException + * @throws FileException|AttachmentException */ public function delete(): bool { @@ -182,13 +181,13 @@ public function rawOut($headers = true, $disposition = 'attachment'): void } /** - * Factory method to initialise the corresponding file object. + * Factory method to initialize the corresponding file object. * * @param string $mode File mode for file open * @return VanillaFile|EncryptedFile * @throws AttachmentException */ - private function getFile($mode = FilesystemFile::MODE_READ) + private function getFile(string $mode = FilesystemFile::MODE_READ): EncryptedFile|VanillaFile { if ($this->encrypted) { return new EncryptedFile(