diff --git a/Adapter/AdapterInterface.php b/Adapter/AdapterInterface.php index 9d42c01..40d7a2b 100644 --- a/Adapter/AdapterInterface.php +++ b/Adapter/AdapterInterface.php @@ -19,7 +19,7 @@ public function has(string $path): bool; * @param array $config * @return bool */ - public function write(string $path, string $contents, array $config = []): bool; + public function write(string $path, $contents, array $config = []): bool; /** * @param string $path @@ -35,7 +35,7 @@ public function writeStream(string $path, $resource, array $config = []): bool; * @param array $config * @return bool */ - public function put(string $path, string $contents, array $config = []): bool; + public function put(string $path, $contents, array $config = []): bool; /** * @param string $path @@ -57,7 +57,7 @@ public function readAndDelete(string $path); * @param array $config * @return bool */ - public function update(string $path, string $contents, array $config = []): bool; + public function update(string $path, $contents, array $config = []): bool; /** * @param string $path @@ -117,7 +117,7 @@ public function createDir(string $dirname, array $config = []): bool; * @param bool $recursive * @return array|null */ - public function listContents(string $directory = '', bool $recursive = false): ?array; + public function listContents(string $directory = '', bool $recursive = false); /** * @param string $path diff --git a/Adapter/FilesystemAdapter.php b/Adapter/FilesystemAdapter.php index e5f14b0..baa6ad2 100644 --- a/Adapter/FilesystemAdapter.php +++ b/Adapter/FilesystemAdapter.php @@ -39,7 +39,7 @@ public function has(string $path): bool * @return bool * @throws \League\Flysystem\FileExistsException */ - public function write(string $path, ?string $contents, array $config = []): bool + public function write(string $path, $contents, array $config = []): bool { return $this->filesystem->write($path, $contents, $config); } @@ -62,7 +62,7 @@ public function writeStream(string $path, $resource, array $config = []): bool * @param array $config * @return bool */ - public function put(string $path, ?string $contents, array $config = []): bool + public function put(string $path, $contents, array $config = []): bool { return $this->filesystem->put($path, $contents, $config); } @@ -95,7 +95,7 @@ public function readAndDelete(string $path) * @return bool * @throws \League\Flysystem\FileNotFoundException */ - public function update(string $path, ?string $contents, array $config = []): bool + public function update(string $path, $contents, array $config = []): bool { return $this->filesystem->update($path, $contents, $config); } @@ -190,7 +190,7 @@ public function createDir(string $dirname, array $config = []): bool * @param bool $recursive * @return array|null */ - public function listContents(string $directory = '', bool $recursive = false): ?array + public function listContents(string $directory = '', bool $recursive = false) { return $this->filesystem->listContents($directory, $recursive); } diff --git a/Block/Adminhtml/Filesystem/Content.php b/Block/Adminhtml/Filesystem/Content.php index d3366b0..c167ae5 100644 --- a/Block/Adminhtml/Filesystem/Content.php +++ b/Block/Adminhtml/Filesystem/Content.php @@ -100,7 +100,7 @@ protected function _construct() /** * @return string|null */ - public function getFilebrowserSetupObject(): ?string + public function getFilebrowserSetupObject() { $setupObject = [ 'newFolderPrompt' => __('New Folder Name:'), @@ -186,7 +186,7 @@ public function getWysiwygModalUrl(): string /** * @return string|null */ - public function getTargetElementId(): ?string + public function getTargetElementId() { return (string)$this->getRequest()->getParam('target_element_id'); } @@ -194,7 +194,7 @@ public function getTargetElementId(): ?string /** * @return string|null */ - public function getModalIdentifier(): ?string + public function getModalIdentifier() { return (string)$this->getRequest()->getParam('identifier'); } diff --git a/Block/Adminhtml/Filesystem/Content/Files.php b/Block/Adminhtml/Filesystem/Content/Files.php index eb071d5..6455eaf 100644 --- a/Block/Adminhtml/Filesystem/Content/Files.php +++ b/Block/Adminhtml/Filesystem/Content/Files.php @@ -146,7 +146,7 @@ public function getFilesCount(): int * @param array $file * @return string|null */ - public function getFileId(array $file): ?string + public function getFileId(array $file) { if(!isset($file['path'])) { return null; @@ -158,7 +158,7 @@ public function getFileId(array $file): ?string * @param array $file * @return string|null */ - public function getFileShortName(array $file): ?string { + public function getFileShortName(array $file) { if(!isset($file['path'])) { return null; } diff --git a/Block/Adminhtml/Filesystem/Content/Uploader.php b/Block/Adminhtml/Filesystem/Content/Uploader.php index fe4a0b8..6920310 100644 --- a/Block/Adminhtml/Filesystem/Content/Uploader.php +++ b/Block/Adminhtml/Filesystem/Content/Uploader.php @@ -40,7 +40,7 @@ protected function _construct() /** * @return string|null */ - protected function _getMediaType(): ?string + protected function _getMediaType() { if ($this->hasData('media_type')) { return $this->_getData('media_type'); diff --git a/Block/Adminhtml/Filesystem/Tree.php b/Block/Adminhtml/Filesystem/Tree.php index 524f3d0..715e2e9 100644 --- a/Block/Adminhtml/Filesystem/Tree.php +++ b/Block/Adminhtml/Filesystem/Tree.php @@ -52,7 +52,7 @@ public function __construct( * @return string|null * @throws \Exception */ - public function getTreeJson(): ?string + public function getTreeJson() { $jsonArray = []; @@ -125,7 +125,7 @@ public function getTreeCurrentPath(): array /** * @return string|null */ - public function getTreeWidgetOptions(): ?string + public function getTreeWidgetOptions() { $serialized = $this->_serializer->serialize([ "folderTree" => [ diff --git a/Helper/Config.php b/Helper/Config.php index 5ba83a6..73738ec 100644 --- a/Helper/Config.php +++ b/Helper/Config.php @@ -69,7 +69,7 @@ public function __construct( /** * @return string|null */ - public function getSource(): ?string + public function getSource() { return $this->_scopeConfig->getValue(self::XPATH_CONFIG_GENERAL_SOURCE); } @@ -85,7 +85,7 @@ public function getFileComparingEnabled(): bool /** * @return string|null */ - public function getLocalPath(): ?string + public function getLocalPath() { return $this->_scopeConfig->getValue(self::XPATH_CONFIG_LOCAL_PATH); } @@ -101,7 +101,7 @@ public function getLocalLock(): int /** * @return string|null */ - public function getFtpHost(): ?string + public function getFtpHost() { return $this->_scopeConfig->getValue(self::XPATH_CONFIG_FTP_HOST); } @@ -109,7 +109,7 @@ public function getFtpHost(): ?string /** * @return string|null */ - public function getFtpUser(): ?string + public function getFtpUser() { return $this->_scopeConfig->getValue(self::XPATH_CONFIG_FTP_USER); } @@ -117,7 +117,7 @@ public function getFtpUser(): ?string /** * @return string|null */ - public function getFtpPassword(): ?string + public function getFtpPassword() { return $this->_scopeConfig->getValue(self::XPATH_CONFIG_FTP_PASSWORD); } @@ -133,7 +133,7 @@ public function getFtpPort(): int /** * @return string|null */ - public function getFtpPath(): ?string + public function getFtpPath() { return $this->_scopeConfig->getValue(self::XPATH_CONFIG_FTP_PATH); } @@ -165,7 +165,7 @@ public function getFtpTimeout(): int /** * @return string|null */ - public function getSftpHost(): ?string + public function getSftpHost() { return $this->_scopeConfig->getValue(self::XPATH_CONFIG_SFTP_HOST); } @@ -181,7 +181,7 @@ public function getSftpPort(): int /** * @return string|null */ - public function getSftpUsername(): ?string + public function getSftpUsername() { return $this->_scopeConfig->getValue(self::XPATH_CONFIG_SFTP_USERNAME); } @@ -189,7 +189,7 @@ public function getSftpUsername(): ?string /** * @return string|null */ - public function getSftpPassword(): ?string + public function getSftpPassword() { return $this->_scopeConfig->getValue(self::XPATH_CONFIG_SFTP_PASSWORD); } @@ -197,7 +197,7 @@ public function getSftpPassword(): ?string /** * @return string|null */ - public function getSftpPrivateKeyPath(): ?string + public function getSftpPrivateKeyPath() { return $this->_scopeConfig->getValue(self::XPATH_CONFIG_SFTP_PRIVATE_KEY_PATH); } @@ -205,7 +205,7 @@ public function getSftpPrivateKeyPath(): ?string /** * @return string|null */ - public function getSftpPrivateKeyContent(): ?string + public function getSftpPrivateKeyContent() { return $this->_scopeConfig->getValue(self::XPATH_CONFIG_SFTP_PRIVATE_KEY_CONTENT); } @@ -213,7 +213,7 @@ public function getSftpPrivateKeyContent(): ?string /** * @return string|null */ - public function getSftpRoot(): ?string + public function getSftpRoot() { return $this->_scopeConfig->getValue(self::XPATH_CONFIG_SFTP_ROOT); } @@ -229,7 +229,7 @@ public function getSftpTimeout(): int /** * @return int|null */ - public function getSftpDirectoryPermissions(): ?int + public function getSftpDirectoryPermissions() { $directoryPermissions = $this->_scopeConfig->getValue(self::XPATH_CONFIG_SFTP_DIRECTORY_PERMISSIONS); diff --git a/Model/Filesystem/Manager.php b/Model/Filesystem/Manager.php index 82dce7e..baedc0e 100644 --- a/Model/Filesystem/Manager.php +++ b/Model/Filesystem/Manager.php @@ -89,7 +89,7 @@ public function __construct( * @return FilesystemAdapter|null * @throws LocalizedException */ - public function create(?string $source = null): ?FilesystemAdapter + public function create($source = null) { if (!$source) { $source = $this->_flysystemConfig->getSource(); @@ -120,7 +120,7 @@ public function create(?string $source = null): ?FilesystemAdapter * @return FilesystemAdapter|null * @throws LocalizedException */ - public function getAdapter(bool $createIfNotExists = true): ?FilesystemAdapter + public function getAdapter(bool $createIfNotExists = true) { if (!$this->_adapter && $createIfNotExists) { $this->create(); @@ -136,7 +136,7 @@ public function getAdapter(bool $createIfNotExists = true): ?FilesystemAdapter * @param FilesystemAdapter|null $adapter * @return void */ - public function setAdapter(?FilesystemAdapter $adapter) + public function setAdapter($adapter) { $this->_adapter = $adapter; } @@ -144,7 +144,7 @@ public function setAdapter(?FilesystemAdapter $adapter) /** * @return string|null */ - public function getPath(): ?string + public function getPath() { return $this->_path; } @@ -152,7 +152,7 @@ public function getPath(): ?string /** * @param string|null $path */ - public function setPath(?string $path) + public function setPath($path) { $this->_path = $path; } @@ -161,7 +161,7 @@ public function setPath(?string $path) * @param string|null $path * @return FilesystemAdapter|null */ - public function createLocalAdapter(?string $path = null): ?FilesystemAdapter + public function createLocalAdapter($path = null) { try { if (empty($path)) { @@ -183,7 +183,7 @@ public function createLocalAdapter(?string $path = null): ?FilesystemAdapter /** * @return FilesystemAdapter|null */ - protected function createFtpAdapter(): ?FilesystemAdapter + protected function createFtpAdapter() { try { $host = $this->_flysystemConfig->getFtpHost(); @@ -219,7 +219,7 @@ protected function createFtpAdapter(): ?FilesystemAdapter /** * @return FilesystemAdapter|null */ - protected function createSftpAdapter(): ?FilesystemAdapter + protected function createSftpAdapter() { try { $host = $this->_flysystemConfig->getSftpHost(); @@ -284,7 +284,7 @@ public function getSession(): Session * @param string|null $identifier * @return Session */ - public function setModalIdentifier(?string $identifier): Session + public function setModalIdentifier($identifier): Session { return $this->getSession()->setFlysystemModalId($identifier); } @@ -292,7 +292,7 @@ public function setModalIdentifier(?string $identifier): Session /** * @return string|null */ - public function getModalIdentifier(): ?string + public function getModalIdentifier() { return $this->getSession()->getFlysystemModalId(); } diff --git a/Model/Filesystem/TmpManager.php b/Model/Filesystem/TmpManager.php index 8f82e8e..d1cb3e1 100644 --- a/Model/Filesystem/TmpManager.php +++ b/Model/Filesystem/TmpManager.php @@ -155,7 +155,7 @@ public function getDirectoryListMedia(): MagentoFilesystem\Directory\WriteInterf /** * @return FilesystemAdapter|null */ - public function create(): ?FilesystemAdapter + public function create() { if(!$this->_adapter) { $path = $this->_directoryList->getAbsolutePath(); @@ -168,9 +168,10 @@ public function create(): ?FilesystemAdapter * @param string $file * @param string|null $content * @return bool + * @throws LocalizedException * @throws \League\Flysystem\FileExistsException */ - public function writeTmp(string $file, ?string $content = null): bool + public function writeTmp(string $file, $content = null): bool { $this->clearTmp(); return $this->getAdapter()->write($this->getTmpPath($file), $content); @@ -249,7 +250,7 @@ public function clearTmp(): bool * @throws LocalizedException * @throws \League\Flysystem\FileExistsException */ - public function writePreview(string $file, ?string $content = null): bool + public function writePreview(string $file, $content = null): bool { $this->clearPreview(); $previewFilename = $this->getUserPreviewDir().'/'.basename($file); @@ -286,7 +287,7 @@ public function clearPreview(): bool /** * @return FilesystemAdapter|null */ - public function getAdapter(): ?FilesystemAdapter + public function getAdapter() { return $this->_adapter; } @@ -294,7 +295,7 @@ public function getAdapter(): ?FilesystemAdapter /** * @param FilesystemAdapter|null $adapter */ - public function setAdapter(?FilesystemAdapter $adapter) + public function setAdapter($adapter) { $this->_adapter = $adapter; } @@ -307,7 +308,7 @@ public function setAdapter(?FilesystemAdapter $adapter) * @throws \League\Flysystem\FileExistsException * @throws \League\Flysystem\FileNotFoundException */ - public function writeWysiwygFile(string $file, ?string $content = null): string + public function writeWysiwygFile(string $file, $content = null): string { $wysiwygFileConst = 'wysiwyg/'.ltrim($file, '/'); $wysiwygFile = $wysiwygFileConst; diff --git a/Model/Filesystem/UploadManager.php b/Model/Filesystem/UploadManager.php index 9da939a..10454fe 100644 --- a/Model/Filesystem/UploadManager.php +++ b/Model/Filesystem/UploadManager.php @@ -81,7 +81,7 @@ public function __construct( /** * @return FilesystemAdapter|null */ - public function create(): ?FilesystemAdapter + public function create() { if(!$this->_adapter) { $this->_adapter = $this->_flysystemFactory->create($this->_flysystemManager->createLocalDriver(self::SERVER_TMP_PATH)); @@ -92,7 +92,7 @@ public function create(): ?FilesystemAdapter /** * @return Uploader|null */ - public function getUploader(): ?Uploader + public function getUploader() { return $this->_uploader; } @@ -100,7 +100,7 @@ public function getUploader(): ?Uploader /** * @return FilesystemAdapter|null */ - public function getAdapter(): ?FilesystemAdapter + public function getAdapter() { return $this->_adapter; } diff --git a/Model/Pool/Modifier/CategoryImage.php b/Model/Pool/Modifier/CategoryImage.php index a1753e2..3837f32 100644 --- a/Model/Pool/Modifier/CategoryImage.php +++ b/Model/Pool/Modifier/CategoryImage.php @@ -57,7 +57,7 @@ public function __construct( * @throws \League\Flysystem\FileNotFoundException * @throws \Magento\Framework\Exception\NoSuchEntityException */ - public function modifyFile(array $data): ?string + public function modifyFile(array $data) { $this->filename = null; if(!isset($data['filename']) || empty($data['filename'])) { @@ -66,17 +66,16 @@ public function modifyFile(array $data): ?string $this->filename = $data['filename']; - $file = $this->createFileArray($this->filename); + $file = $this->createFileArray(); $result = $this->_tmpManager->createCategoryTmp($file); return json_encode($result); } /** - * @param string $filename * @return array + * @throws LocalizedException * @throws \League\Flysystem\FileNotFoundException - * @throws \Magento\Framework\Exception\LocalizedException */ protected function createFileArray(): array { $file = [ diff --git a/Model/Pool/Modifier/CmsWysiwygImage.php b/Model/Pool/Modifier/CmsWysiwygImage.php index 98ab337..417cd9a 100644 --- a/Model/Pool/Modifier/CmsWysiwygImage.php +++ b/Model/Pool/Modifier/CmsWysiwygImage.php @@ -72,7 +72,7 @@ public function __construct( * @throws \League\Flysystem\FileNotFoundException * @throws \Magento\Framework\Exception\NoSuchEntityException */ - public function modifyFile(array $data): ?string + public function modifyFile(array $data) { $this->filename = null; if (!isset($data['filename']) || empty($data['filename'])) { diff --git a/Model/Pool/Modifier/ProductImage.php b/Model/Pool/Modifier/ProductImage.php index c5e10cb..d3f7843 100644 --- a/Model/Pool/Modifier/ProductImage.php +++ b/Model/Pool/Modifier/ProductImage.php @@ -56,7 +56,7 @@ public function __construct( * @throws \League\Flysystem\FileNotFoundException * @throws \Magento\Framework\Exception\LocalizedException */ - public function modifyFile(array $data): ?string + public function modifyFile(array $data) { $this->filename = null; if(!isset($data['filename']) || empty($data['filename'])) { diff --git a/Model/Pool/ModifierInterface.php b/Model/Pool/ModifierInterface.php index a206636..da633c2 100644 --- a/Model/Pool/ModifierInterface.php +++ b/Model/Pool/ModifierInterface.php @@ -5,7 +5,7 @@ interface ModifierInterface { /** * @param array $data - * @return string + * @return string|null */ - public function modifyFile(array $data): ?string; + public function modifyFile(array $data); }