From 3a6086bdf9af56aeda7e87c04fb34ac615ec224f Mon Sep 17 00:00:00 2001 From: Ihor M Date: Fri, 31 Oct 2025 17:11:33 +0200 Subject: [PATCH 1/5] update coding standard and add strict types --- Api/BreezeThemeDetectionInterface.php | 4 +- Api/GetCategoryByProductInterface.php | 4 + Api/GetModuleInfoInterface.php | 6 +- Api/GetModuleVersionInterface.php | 2 + Api/GetParentProductIdsInterface.php | 4 + Api/GetWebsitesMapInterface.php | 4 + Api/HyvaThemeDetectionInterface.php | 4 +- Api/SecureHtmlRendererInterface.php | 3 +- Block/Adminhtml/Edit/BackButton.php | 4 + Block/Adminhtml/Edit/CreateButton.php | 4 + Block/Adminhtml/Edit/DeleteButton.php | 6 + Block/Adminhtml/Edit/DuplicateButton.php | 6 + Block/Adminhtml/Edit/GenericButton.php | 4 +- Block/Adminhtml/Edit/PreviewButton.php | 6 + Block/Adminhtml/Edit/ResetButton.php | 4 + .../Adminhtml/Edit/SaveAndContinueButton.php | 4 + Block/Adminhtml/Edit/SaveButton.php | 4 + Block/Adminhtml/HyvaThemeChecker.php | 8 +- Block/Adminhtml/Linv.php | 4 + .../System/Config/Form/ExtensionsInfo.php | 25 +- Block/Adminhtml/System/Config/Form/Info.php | 221 +++++++++++++++--- .../System/Config/Form/ProductKeyField.php | 27 ++- Block/JsScript.php | 6 + Controller/Adminhtml/Actions.php | 127 ++++++---- Controller/Adminhtml/Activate/Extension.php | 23 +- Cron/Sections.php | 5 + Model/AbstractThemeDetection.php | 12 +- Model/AdminNotificationFeed.php | 37 +-- Model/BreezeThemeDetection.php | 4 + Model/Config.php | 31 +-- Model/GetCategoryByProduct.php | 6 +- Model/GetModuleInfo.php | 27 ++- Model/GetModuleVersion.php | 3 + Model/GetParentProductIds.php | 6 +- Model/GetWebsitesMap.php | 5 +- Model/HyvaThemeDetection.php | 4 + .../Mail/Template/TransportBuilder.php | 35 +-- .../CollectionOptimizedForSqlValidator.php | 5 +- .../Rule/Model/Condition/Sql/Builder.php | 29 ++- Model/Section.php | 46 ++-- Model/Section/Info.php | 12 + Model/SetLinvFlag.php | 18 +- Model/UrlChecker.php | 7 + Model/View/Helper/SecureHtmlRenderer.php | 9 +- Observer/ConfigObserver.php | 14 +- ...redispathAdminActionControllerObserver.php | 21 +- .../Backend/Model/Menu/BuilderPlugin.php | 28 ++- .../Framework/View/TemplateEngine/Php.php | 16 +- Setup/Patch/Data/UpdateWelcomeBlogPost.php | 16 +- .../templates/hyvathemechecker.phtml | 26 ++- view/adminhtml/templates/linv.phtml | 18 +- view/adminhtml/templates/vendors.phtml | 42 +++- view/adminhtml/web/css/source/_module.less | 2 +- .../js/isCustomerConsentProvided.phtml | 8 +- view/base/templates/js/objToUrlParams.phtml | 2 +- 55 files changed, 776 insertions(+), 232 deletions(-) diff --git a/Api/BreezeThemeDetectionInterface.php b/Api/BreezeThemeDetectionInterface.php index b1f1ad7..6d78134 100644 --- a/Api/BreezeThemeDetectionInterface.php +++ b/Api/BreezeThemeDetectionInterface.php @@ -12,7 +12,9 @@ interface BreezeThemeDetectionInterface { /** - * @param $storeId + * Breeze theme detect by store id + * + * @param mixed $storeId * @return bool */ public function execute($storeId = null): bool; diff --git a/Api/GetCategoryByProductInterface.php b/Api/GetCategoryByProductInterface.php index 050861f..262dd68 100644 --- a/Api/GetCategoryByProductInterface.php +++ b/Api/GetCategoryByProductInterface.php @@ -4,6 +4,8 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Api; /** @@ -15,6 +17,8 @@ interface GetCategoryByProductInterface { /** + * Get category by product + * * @param mixed $product * @param mixed $storeId * @returnmixed diff --git a/Api/GetModuleInfoInterface.php b/Api/GetModuleInfoInterface.php index 62009f7..b47ba1b 100644 --- a/Api/GetModuleInfoInterface.php +++ b/Api/GetModuleInfoInterface.php @@ -4,6 +4,8 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Api; use Magento\Framework\DataObject; @@ -17,7 +19,9 @@ interface GetModuleInfoInterface { /** - * @param $moduleName + * Get data by module + * + * @param string $moduleName * @return array|DataObject|mixed */ public function execute($moduleName = null); diff --git a/Api/GetModuleVersionInterface.php b/Api/GetModuleVersionInterface.php index 86e4ee8..3c6bb40 100644 --- a/Api/GetModuleVersionInterface.php +++ b/Api/GetModuleVersionInterface.php @@ -4,6 +4,8 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Api; /** diff --git a/Api/GetParentProductIdsInterface.php b/Api/GetParentProductIdsInterface.php index 2d992bc..a17620c 100644 --- a/Api/GetParentProductIdsInterface.php +++ b/Api/GetParentProductIdsInterface.php @@ -4,6 +4,8 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Api; /** @@ -15,6 +17,8 @@ interface GetParentProductIdsInterface { /** + * Get parent product ids + * * @api * @param array $productIds * @return array diff --git a/Api/GetWebsitesMapInterface.php b/Api/GetWebsitesMapInterface.php index adf186c..485198f 100644 --- a/Api/GetWebsitesMapInterface.php +++ b/Api/GetWebsitesMapInterface.php @@ -4,6 +4,8 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Api; /** @@ -15,6 +17,8 @@ interface GetWebsitesMapInterface { /** + * Get websites + * * @api * @return array */ diff --git a/Api/HyvaThemeDetectionInterface.php b/Api/HyvaThemeDetectionInterface.php index f9c795d..192c6a8 100644 --- a/Api/HyvaThemeDetectionInterface.php +++ b/Api/HyvaThemeDetectionInterface.php @@ -12,7 +12,9 @@ interface HyvaThemeDetectionInterface { /** - * @param $storeId + * Hyva detector + * + * @param mixed $storeId * @return bool */ public function execute($storeId = null): bool; diff --git a/Api/SecureHtmlRendererInterface.php b/Api/SecureHtmlRendererInterface.php index af37ece..55e49bf 100644 --- a/Api/SecureHtmlRendererInterface.php +++ b/Api/SecureHtmlRendererInterface.php @@ -1,5 +1,4 @@ hyvaThemeDetection =$hyvaThemeDetection; } - /** - * @return array - */ + /** + * Get group modules + * + * @return array + */ public function getWitchModuleIsInstalled(): array { $moduleGroups = [ diff --git a/Block/Adminhtml/Linv.php b/Block/Adminhtml/Linv.php index 28e6cdb..2cece26 100644 --- a/Block/Adminhtml/Linv.php +++ b/Block/Adminhtml/Linv.php @@ -42,6 +42,8 @@ public function __construct( } /** + * Get items config + * * @return array */ public function getItems(): array @@ -72,6 +74,8 @@ public function getItems(): array } /** + * Get messages + * * @return array */ public function getMessages():array diff --git a/Block/Adminhtml/System/Config/Form/ExtensionsInfo.php b/Block/Adminhtml/System/Config/Form/ExtensionsInfo.php index 239302d..8923009 100644 --- a/Block/Adminhtml/System/Config/Form/ExtensionsInfo.php +++ b/Block/Adminhtml/System/Config/Form/ExtensionsInfo.php @@ -3,6 +3,9 @@ * Copyright © Magefan (support@magefan.com). All rights reserved. * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ + +declare(strict_types=1); + namespace Magefan\Community\Block\Adminhtml\System\Config\Form; use Magento\Config\Block\System\Config\Form\Field; @@ -34,6 +37,7 @@ class ExtensionsInfo extends Field * @param Context $context * @param ModuleListInterface $moduleList * @param GetModuleVersionInterface $getModuleVersion + * @param GetModuleInfoInterface $getModuleInfo * @param array $data */ public function __construct( @@ -50,6 +54,8 @@ public function __construct( } /** + * Render extension info + * * @param AbstractElement $element * @return string */ @@ -88,10 +94,14 @@ public function render(AbstractElement $element) if ((!$module && $listKey != 'new_extensions') || ($module && $listKey == 'new_extensions')) { continue; } - if ($listKey == 'up_to_date' && version_compare($this->getModuleVersion->execute($moduleName), $moduleInfo->getVersion()) < 0) { + if ($listKey == 'up_to_date' && + version_compare($this->getModuleVersion->execute($moduleName), $moduleInfo->getVersion()) < 0 + ) { continue; } - if ($listKey == 'need_update' && version_compare($this->getModuleVersion->execute($moduleName), $moduleInfo->getVersion()) >= 0) { + if ($listKey == 'need_update' && + version_compare($this->getModuleVersion->execute($moduleName), $moduleInfo->getVersion()) >= 0 + ) { continue; } @@ -103,12 +113,15 @@ public function render(AbstractElement $element) $version = $this->getModuleVersion->execute($moduleName); } - $html .= ''; - $html .= '' . $this->escapeHtml($moduleInfo->getProductName()) . ''; + $html .= '' . + $this->escapeHtml($moduleInfo->getProductName()) . ''; $html .= '' . $this->escapeHtml($version) . ''; - $html .= '' . $this->escapeHtml(__('Change Log')) . ''; - $html .= ''. $this->escapeHtml(__('User Guide')). ''; + $html .= '' + . $this->escapeHtml(__('Change Log')) . ''; + $html .= ''. + $this->escapeHtml(__('User Guide')). ''; $html .= ''; } diff --git a/Block/Adminhtml/System/Config/Form/Info.php b/Block/Adminhtml/System/Config/Form/Info.php index 5ec5c28..af1dcb3 100755 --- a/Block/Adminhtml/System/Config/Form/Info.php +++ b/Block/Adminhtml/System/Config/Form/Info.php @@ -4,11 +4,16 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Block\Adminhtml\System\Config\Form; use Magefan\Community\Api\GetModuleVersionInterface; use Magefan\Community\Api\SecureHtmlRendererInterface; use Magefan\Community\Api\GetModuleInfoInterface; +use Magento\Backend\Block\Template\Context; +use Magento\Framework\Data\Form\Element\AbstractElement; +use Magento\Framework\Module\ModuleListInterface; /** * Admin Magefan configurations information block @@ -16,7 +21,7 @@ class Info extends \Magento\Config\Block\System\Config\Form\Field { /** - * @var \Magento\Framework\Module\ModuleListInterface + * @var ModuleListInterface */ protected $moduleList; @@ -36,16 +41,16 @@ class Info extends \Magento\Config\Block\System\Config\Form\Field protected $getModuleInfo; /** - * @param \Magento\Framework\Module\ModuleListInterface $moduleList - * @param \Magento\Backend\Block\Template\Context $context + * @param ModuleListInterface $moduleList + * @param Context $context * @param array $data * @param GetModuleVersionInterface|null $getModuleVersion * @param SecureHtmlRendererInterface|null $mfSecureRenderer * @param ModuleInfoInterface|null $getModuleInfo */ public function __construct( - \Magento\Framework\Module\ModuleListInterface $moduleList, - \Magento\Backend\Block\Template\Context $context, + ModuleListInterface $moduleList, + Context $context, array $data = [], ?GetModuleVersionInterface $getModuleVersion = null, ?SecureHtmlRendererInterface $mfSecureRenderer = null, @@ -64,10 +69,11 @@ public function __construct( /** * Return info block html - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * + * @param AbstractElement $element * @return string */ - public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) + public function render(AbstractElement $element) { $moduleName = $this->getModuleName(); @@ -104,60 +110,146 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele $utmParam = '?utm_source=admin&utm_medium=config'; if ($moduleInfo->getMaxPlan()) { - $canUpgradeToMaxPlan = !$this->getModuleVersion->execute($moduleName . ucfirst($moduleInfo->getMaxPlan())); + $canUpgradeToMaxPlan = !$this->getModuleVersion->execute( + $moduleName . ucfirst($moduleInfo->getMaxPlan()) + ); } else { $canUpgradeToMaxPlan = false; } + $moduleImage = $moduleImage ? + $this->escapeHtml($moduleImage) : + ('https://mag' . 'ef' . 'an.com/media/magefan-logo-2025.png'); + + $documentationUrl = $this->escapeHtml($moduleInfo->getDocumentationUrl()); + $html = '
- developed by - Mage' . 'fan + developed by + Mage' . 'fan ' . ($latestVersion ? ' - - - - User Guide + + + + + + + User Guide + + ' : '') . '
- +
'; if ($canUpgradeToMaxPlan) { - $html .= ''; + $escapedUrl = $this->escapeHtml($moduleUrl . '/pricing' . $utmParam); + $html .= ''; } if ($newVersionAvailable) { - $html .= ''; + $partUpdateProductUrl = 'fan.com/downloadable/customer/products'; + $html .= ''; } $html .= '
'; if ($newVersionAvailable) { - $html .= '
Version v' . $this->escapeHtml($latestVersion) . ' is available
'; + $html .= '
+ Version v' . $this->escapeHtml($latestVersion) . ' is available +
'; } + + $fontPath = "Magefan_Community::fonts/variable/LDIoaomQNQcsA88c7O9yZ4KMCoOg4Ko20yw.woff2"; $html .= '
'; @@ -202,6 +351,7 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele /** * Return extension url + * * @return string */ protected function getModuleUrl() @@ -211,6 +361,7 @@ protected function getModuleUrl() /** * Return extension title + * * @return string */ protected function getModuleTitle() diff --git a/Block/Adminhtml/System/Config/Form/ProductKeyField.php b/Block/Adminhtml/System/Config/Form/ProductKeyField.php index b581a3d..9e5f448 100644 --- a/Block/Adminhtml/System/Config/Form/ProductKeyField.php +++ b/Block/Adminhtml/System/Config/Form/ProductKeyField.php @@ -4,22 +4,24 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Block\Adminhtml\System\Config\Form; use Magento\Config\Block\System\Config\Form\Field; -use Magento\Backend\Block\Template\Context; use Magefan\Community\Model\Section; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Data\Form\Element\AbstractElement; class ProductKeyField extends Field { /** * Retrieve HTML markup for given form element * - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element * @return string */ - public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) + public function render(AbstractElement $element) { $objectManager = ObjectManager::getInstance(); $fieldConfig = $element->getFieldConfig(); @@ -31,21 +33,30 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele if (!$element->getComment()) { $url = 'htt' . 'ps' . ':' . '/'. '/'. 'ma' . 'g' . 'ef' . 'an' . '.' . 'co' . 'm/' . 'down' . 'loa' . 'dab' . 'le/' . 'cus' . 'tomer' . '/' . 'pr' . 'od' . 'ucts' . '/'; - $element->setComment('You can find product key in your Magefan account.'); + $element->setComment( + 'You can find product key in your Magefan account.' + ); } return parent::render($element); } else { $config = ObjectManager::getInstance()->get(\Magefan\Community\Model\Config::class); $bp = $section->getName() . '/' . 'g' . 'e' . 'n' . 'e' . 'r' . 'a' . 'l' . '/' ; if (!$config->getConfig($bp . Section::ACTIVE) && !$section->getType()) { - $url = 'ht' . 'tps'. ':' . '/'. '/'. 'ma' . 'g' . 'ef' . 'an' . '.' . 'c' . 'o' . 'm' . '/' . 'mp' . 'k/a' . 'cti' . 'vat' . 'e/e' . 'xte' . 'nsi' . 'on/' . 'ret' . 'urn_' . 'ur' . 'l/' . - base64_encode($this->getUrl('m' . 'f' . 'co' . 'mm' . 'uni' . 'ty/' . 'act' . 'iva' . 'te/ext' . 'ens' . 'ion', ['section' => $section->getName()])) - . '/mo' . 'dul' . 'e/' . $section->getModuleName() . '/se' . 'cti' . 'on/' . $section->getName(); + $url = 'ht' . 'tps'. ':' . '/'. '/'. 'ma' . 'g' . 'ef' . 'an' . '.' . 'c' . 'o' . 'm' . '/' . 'mp' . + 'k/a' . 'cti' . 'vat' . 'e/e' . 'xte' . 'nsi' . 'on/' . 'ret' . 'urn_' . 'ur' . 'l/' . + base64_encode($this->getUrl('m' . 'f' . 'co' . 'mm' . 'uni' . 'ty/' . 'act' . 'iva' . + 'te/ext' . 'ens' . 'ion', ['section' => $section->getName()])) . '/mo' . + 'dul' . 'e/' . $section->getModuleName() . '/se' . 'cti' . 'on/' . $section->getName(); return ' - diff --git a/Block/JsScript.php b/Block/JsScript.php index 183e50c..6cd250e 100644 --- a/Block/JsScript.php +++ b/Block/JsScript.php @@ -24,6 +24,8 @@ class JsScript extends Template private $jsMethod; /** + * Set method + * * @param string $method * @return JsScript */ @@ -34,6 +36,8 @@ public function setMethod(string $method): JsScript } /** + * Get js template + * * @return string */ public function getTemplate() @@ -56,6 +60,8 @@ public function getWebsiteId(): int } /** + * Add custom html + * * @return string */ public function toHtml() diff --git a/Controller/Adminhtml/Actions.php b/Controller/Adminhtml/Actions.php index c660a4d..63ed550 100644 --- a/Controller/Adminhtml/Actions.php +++ b/Controller/Adminhtml/Actions.php @@ -4,10 +4,17 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Controller\Adminhtml; +use Exception; use Magento\Framework\App\Request\DataPersistorInterface; use Magento\Backend\App\Action\Context; +use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Model\AbstractModel; +use Magento\Framework\Registry; /** * Abstract admin controller @@ -15,67 +22,55 @@ abstract class Actions extends \Magento\Backend\App\Action { /** - * Form session key * @var string */ protected $_formSessionKey; /** - * Allowed Key * @var string */ protected $_allowedKey; /** - * Model class name * @var string */ protected $_modelClass; /** - * Active menu key * @var string */ protected $_activeMenu; /** - * Store config section key * @var string */ protected $_configSection; /** - * Request id key * @var string */ protected $_idKey = 'id'; /** - * Status field name * @var string */ protected $_statusField = 'status'; /** - * Save request params key * @var string */ protected $_paramsHolder; /** - * Model Object - * @var \Magento\Framework\Model\AbstractModel + * @var AbstractModel */ protected $_model; /** - * Core registry - * - * @var \Magento\Framework\Registry + * @var Registry */ protected $_coreRegistry = null; - /** * @var DataPersistorInterface */ @@ -95,7 +90,8 @@ public function __construct( /** * Action execute - * @return \Magento\Framework\Controller\ResultInterface + * + * @return ResultInterface */ public function execute() { @@ -112,6 +108,7 @@ public function execute() /** * Index action + * * @return void */ protected function _indexAction() @@ -131,6 +128,7 @@ protected function _indexAction() /** * Grid action + * * @return void */ protected function _gridAction() @@ -141,6 +139,7 @@ protected function _gridAction() /** * New action + * * @return void */ protected function _newAction() @@ -150,17 +149,19 @@ protected function _newAction() /** * Edit action + * * @return void + * @throws Exception */ public function _editAction() { + $model = $this->_getModel(); + $id = $this->getRequest()->getParam('id'); + if (!$model->getId() && $id) { + throw new Exception("Item is not longer exist.", 1); + } try { - $model = $this->_getModel(); - $id = $this->getRequest()->getParam('id'); - if (!$model->getId() && $id) { - throw new \Exception("Item is not longer exist.", 1); - } $this->_getRegistry()->register('current_model', $model); $this->_view->loadLayout(); @@ -192,7 +193,7 @@ public function _editAction() } $this->_view->renderLayout(); - } catch (\Exception $e) { + } catch (Exception $e) { $this->messageManager->addException( $e, __( @@ -206,16 +207,18 @@ public function _editAction() /** * Retrieve model name - * @param boolean $plural + * + * @param AbstractModel $model * @return string */ - protected function _getModelName(\Magento\Framework\Model\AbstractModel $model) + protected function _getModelName(AbstractModel $model) { return $model->getName() ?: $model->getTitle(); } /** * Save action + * * @return void */ public function _saveAction() @@ -235,22 +238,28 @@ public function _saveAction() unset($params[$idFieldName]); } $model->addData($params); - - $this->_eventManager->dispatch('magefan_' . $this->getRequest()->getModuleName() . '_' . $this->getRequest()->getControllerName() . '_form_before_save', ['model' => $model]); + $moduleName = $this->getRequest()->getModuleName(); + $this->_eventManager->dispatch( + 'magefan_' . $moduleName . '_' . $this->getRequest()->getControllerName() . '_form_before_save', + ['model' => $model] + ); $this->_beforeSave($model, $request); $model->save(); $this->_afterSave($model, $request); - $this->_eventManager->dispatch('magefan_' . $this->getRequest()->getModuleName() . '_' . $this->getRequest()->getControllerName() . '_form_after_save', ['model' => $model]); + $this->_eventManager->dispatch( + 'magefan_' . $moduleName . '_' . $this->getRequest()->getControllerName() . '_form_after_save', + ['model' => $model] + ); $this->messageManager->addSuccess(__('%1 has been saved.', $model->getOwnTitle())); $this->_setFormData(false); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError(nl2br($e->getMessage())); $this->_setFormData($params); - } catch (\Exception $e) { + } catch (Exception $e) { $this->messageManager->addException( $e, __( @@ -295,22 +304,24 @@ public function _saveAction() } /** - * Duplicat action + * Duplicate action + * * @return void + * @throws Exception */ protected function _duplicateAction() { - try { - $originModel = $this->_getModel(); - if (!$originModel->getId()) { - throw new \Exception("Item is not longer exist.", 1); - } + $originModel = $this->_getModel(); + if (!$originModel->getId()) { + throw new Exception("Item is not longer exist.", 1); + } + try { $model = $originModel->duplicate(); $this->messageManager->addSuccess(__('%1 has been duplicated.', $model->getOwnTitle())); $this->_redirect('*/*/edit', [$this->_idKey => $model->getId()]); - } catch (\Exception $e) { + } catch (Exception $e) { $this->messageManager->addException( $e, __( @@ -323,8 +334,10 @@ protected function _duplicateAction() } } + // @codingStandardsIgnoreStart /** * Before model Save action + * * @return void */ protected function _beforeSave($model, $request) @@ -333,6 +346,7 @@ protected function _beforeSave($model, $request) /** * After model action + * * @return void */ protected function _afterSave($model, $request) @@ -341,6 +355,7 @@ protected function _afterSave($model, $request) /** * Before action + * * @return void */ protected function _beforeAction() @@ -349,14 +364,17 @@ protected function _beforeAction() /** * After action + * * @return void */ protected function _afterAction() { } + // @codingStandardsIgnoreEnd /** * Delete action + * * @return void */ protected function _deleteAction() @@ -375,7 +393,7 @@ protected function _deleteAction() } catch (\Magento\Framework\Exception\LocalizedException $e) { $error = true; $this->messageManager->addError($e->getMessage()); - } catch (\Exception $e) { + } catch (Exception $e) { $error = true; $this->messageManager->addException( $e, @@ -398,6 +416,7 @@ protected function _deleteAction() /** * Change status action + * * @return void */ protected function _massStatusAction() @@ -416,12 +435,12 @@ protected function _massStatusAction() $status = $this->getRequest()->getParam('status'); $statusFieldName = $this->_statusField; - if (is_null($status)) { - throw new \Exception(__('Parameter "Status" missing in request data.')); + if ($status === null) { + throw new Exception(__('Parameter "Status" missing in request data.')); } - if (is_null($statusFieldName)) { - throw new \Exception(__('Status Field Name is not specified.')); + if ($statusFieldName === null) { + throw new Exception(__('Status Field Name is not specified.')); } foreach ($ids as $id) { @@ -433,7 +452,7 @@ protected function _massStatusAction() } catch (\Magento\Framework\Exception\LocalizedException $e) { $error = true; $this->messageManager->addError($e->getMessage()); - } catch (\Exception $e) { + } catch (Exception $e) { $error = true; $this->messageManager->addException( $e, @@ -456,6 +475,7 @@ protected function _massStatusAction() /** * Go to config section action + * * @return void */ protected function _configAction() @@ -465,6 +485,8 @@ protected function _configAction() /** * Set form data + * + * @param mixed $data * @return $this */ protected function _setFormData($data = null) @@ -487,6 +509,7 @@ protected function _setFormData($data = null) /** * Filter request params + * * @param array $data * @return array */ @@ -497,12 +520,13 @@ protected function filterParams($data) /** * Get core registry + * * @return void */ protected function _getRegistry() { - if (is_null($this->_coreRegistry)) { - $this->_coreRegistry = $this->_objectManager->get(\Magento\Framework\Registry::class); + if ($this->_coreRegistry === null) { + $this->_coreRegistry = $this->_objectManager->get(Registry::class); } return $this->_coreRegistry; } @@ -519,11 +543,14 @@ protected function _isAllowed() /** * Retrieve model object - * @return \Magento\Framework\Model\AbstractModel + * + * @param mixed $load + * @return AbstractModel + * @throws LocalizedException */ protected function _getModel($load = true) { - if (is_null($this->_model)) { + if ($this->_model === null) { $this->_model = $this->_objectManager->create($this->_modelClass); $id = (int)$this->getRequest()->getParam($this->_idKey); @@ -533,14 +560,21 @@ protected function _getModel($load = true) } if ($id && $load) { + $module = $this->getRequest()->getModuleName(); + $controler = $this->getRequest()->getControllerName(); $this->_model->load($id); - $this->_eventManager->dispatch('magefan_' . $this->getRequest()->getModuleName() . '_' . $this->getRequest()->getControllerName() . '_form_load_model_after', ['model' => $this->_model]); + $this->_eventManager->dispatch( + 'magefan_' . $module . '_' . $controler . '_form_load_model_after', + ['model' => $this->_model] + ); } } return $this->_model; } /** + * Get filter input + * * @param array $filterRules * @param array $validatorRules * @param array|null $data @@ -548,6 +582,7 @@ protected function _getModel($load = true) */ protected function getFilterInput($filterRules, $validatorRules, $data) { + // @codingStandardsIgnoreLine if (class_exists('\Magento\Framework\Filter\FilterInput')) { $inputFilter = new \Magento\Framework\Filter\FilterInput( $filterRules, @@ -555,11 +590,13 @@ protected function getFilterInput($filterRules, $validatorRules, $data) $data ); } else { + // @codingStandardsIgnoreStart $inputFilter = new \Zend_Filter_Input( $filterRules, [], $data ); + // @codingStandardsIgnoreEnd } return $inputFilter; diff --git a/Controller/Adminhtml/Activate/Extension.php b/Controller/Adminhtml/Activate/Extension.php index 1f3d5d8..5fc226b 100644 --- a/Controller/Adminhtml/Activate/Extension.php +++ b/Controller/Adminhtml/Activate/Extension.php @@ -11,6 +11,9 @@ use Magento\Backend\App\Action\Context; use Magento\Framework\App\Config\Storage\WriterInterface; use Magento\Framework\App\Cache\TypeListInterface; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Controller\Result\Redirect; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\Cache\Type\Config; @@ -53,8 +56,9 @@ public function __construct( } /** - * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\Result\Redirect|\Magento\Framework\Controller\ResultInterface - * @throws NoSuchEntityException + * Activate extension + * + * @return ResponseInterface|Redirect|ResultInterface */ public function execute() { @@ -69,6 +73,7 @@ public function execute() throw new LocalizedException(__('Section param is missing. Please contact Magefan support.')); } + // @codingStandardsIgnoreLine $urlInfo = parse_url($this->_url->getCurrentUrl()); $domain = isset($urlInfo['host']) ? $urlInfo['host'] : ''; @@ -78,11 +83,21 @@ public function execute() throw new LocalizedException(__('Invalid Activation Key. Please contact Magefan support.')); } - $this->configWriter->save($section . '/g'.'e'.'n'.'e'.'r'.'a'.'l'.'/'.Section::ACTIVE, 1, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0); + $this->configWriter->save( + $section . '/g'.'e'.'n'.'e'.'r'.'a'.'l'.'/'.Section::ACTIVE, + 1, + ScopeConfigInterface::SCOPE_TYPE_DEFAULT, + 0 + ); $this->cacheTypeList->cleanType(Config::TYPE_IDENTIFIER); $this->messageManager->addSuccess(__('Thank you. Extension has been activated.')); - return $this->resultRedirectFactory->create()->setUrl($this->_url->getUrl('adminhtml/system_config/edit', ['section' => $section])); + return $this->resultRedirectFactory->create()->setUrl( + $this->_url->getUrl( + 'adminhtml/system_config/edit', + ['section' => $section] + ) + ); } catch (LocalizedException $e) { $this->messageManager->addError($e->getMessage()); return $this->resultRedirectFactory->create()->setUrl($this->_url->getUrl('adminhtml')); diff --git a/Cron/Sections.php b/Cron/Sections.php index 7f9f73d..08140e9 100644 --- a/Cron/Sections.php +++ b/Cron/Sections.php @@ -4,6 +4,8 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Cron; use Magefan\Community\Model\SectionFactory; @@ -38,6 +40,7 @@ class Sections * @param ResourceConnection $resource * @param SectionFactory $sectionFactory * @param Info $info + * @param SetLinvFlag $setLinvFlag */ public function __construct( ResourceConnection $resource, @@ -53,6 +56,8 @@ public function __construct( /** * Execute cron job + * + * @return void */ public function execute() { diff --git a/Model/AbstractThemeDetection.php b/Model/AbstractThemeDetection.php index 0876c3e..b93a001 100644 --- a/Model/AbstractThemeDetection.php +++ b/Model/AbstractThemeDetection.php @@ -61,17 +61,23 @@ public function __construct( } /** + * Get theme module name + * * @return string */ abstract public function getThemeModuleName(): string; /** + * Get theme name + * * @return string */ abstract public function getThemeName():string; /** - * @param $storeId + * Get theme + * + * @param mixed $storeId * @return bool * @throws NoSuchEntityException */ @@ -108,7 +114,9 @@ public function execute($storeId = null): bool } /** - * @param $storeId + * Is used theme by store + * + * @param mixed $storeId * @return bool */ private function isThemeInUse($storeId) diff --git a/Model/AdminNotificationFeed.php b/Model/AdminNotificationFeed.php index 311a160..1e74d48 100644 --- a/Model/AdminNotificationFeed.php +++ b/Model/AdminNotificationFeed.php @@ -4,19 +4,23 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Model; use Magefan\Community\Api\GetModuleVersionInterface; +use Magento\Backend\Model\Auth\Session; use Magento\Framework\App\DeploymentConfig; -use Magento\Framework\App\ObjectManager; use Magento\Framework\App\ProductMetadataInterface; use Magento\Framework\Config\ConfigOptionsListConstants; use Magento\Framework\Data\Collection\AbstractDb; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\HTTP\Adapter\Curl; use Magento\Framework\HTTP\Adapter\CurlFactory; -use Magento\Framework\Model\AbstractModel; use Magento\Framework\Model\Context; use Magento\Framework\Model\ResourceModel\AbstractResource; +use Magento\Framework\Module\Manager; +use Magento\Framework\Module\ModuleListInterface; use Magento\Framework\Registry; use Magento\Framework\UrlInterface; use SimpleXMLElement; @@ -26,7 +30,7 @@ class AdminNotificationFeed extends \Magento\Framework\Model\AbstractModel /** * @var string */ - const MAGEFAN_CACHE_KEY = 'magefan_admin_notifications_lastcheck' ; + public const MAGEFAN_CACHE_KEY = 'magefan_admin_notifications_lastcheck' ; /** * @var string @@ -62,17 +66,17 @@ class AdminNotificationFeed extends \Magento\Framework\Model\AbstractModel protected $urlBuilder; /** - * @var \Magento\Backend\Model\Auth\Session + * @var Session */ protected $_backendAuthSession; /** - * @var \Magento\Framework\Module\ModuleListInterface + * @var ModuleListInterface */ protected $_moduleList; /** - * @var \Magento\Framework\Module\Manager + * @var Manager */ protected $_moduleManager; @@ -89,9 +93,9 @@ class AdminNotificationFeed extends \Magento\Framework\Model\AbstractModel /** * @param Context $context * @param Registry $registry - * @param \Magento\Backend\Model\Auth\Session $backendAuthSession - * @param \Magento\Framework\Module\ModuleListInterface $moduleList - * @param \Magento\Framework\Module\Manager $moduleManager + * @param Session $backendAuthSession + * @param ModuleListInterface $moduleList + * @param Manager $moduleManager * @param CurlFactory $curlFactory * @param DeploymentConfig $deploymentConfig * @param ProductMetadataInterface $productMetadata @@ -101,13 +105,14 @@ class AdminNotificationFeed extends \Magento\Framework\Model\AbstractModel * @param AbstractResource|null $resource * @param AbstractDb|null $resourceCollection * @param array $data + * @throws LocalizedException */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Backend\Model\Auth\Session $backendAuthSession, - \Magento\Framework\Module\ModuleListInterface $moduleList, - \Magento\Framework\Module\Manager $moduleManager, + Session $backendAuthSession, + ModuleListInterface $moduleList, + Manager $moduleManager, \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory, \Magento\Framework\App\DeploymentConfig $deploymentConfig, \Magento\Framework\App\ProductMetadataInterface $productMetadata, @@ -148,10 +153,11 @@ protected function _construct() */ public function getFeedUrl() { - if (is_null($this->_feedUrl)) { + if ($this->_feedUrl === null) { $this->_feedUrl = 'https://mage'.'fan' .'.c'.'om/community/notifications'.'/'.'feed/'; } + // phpcs:ignore Magento2.Functions.DiscouragedFunction $urlInfo = parse_url($this->urlBuilder->getBaseUrl()); $domain = isset($urlInfo['host']) ? $urlInfo['host'] : ''; $url = $this->_feedUrl . 'domain/' . urlencode($domain); @@ -369,17 +375,22 @@ public function getFeedXml() */ private function escapeString(SimpleXMLElement $data) { + // phpcs:ignore Magento2.Functions.DiscouragedFunction return htmlspecialchars((string)$data); } /** + * Get inbox factory + * * @return mixed */ private function getInboxFactory() { if (null === $this->_inboxFactory) { + // phpcs:disable $this->_inboxFactory = \Magento\Framework\App\ObjectManager::getInstance() ->get(\Magento\AdminNotification\Model\InboxFactory::class); + // phpcs:enable } return $this->_inboxFactory; diff --git a/Model/BreezeThemeDetection.php b/Model/BreezeThemeDetection.php index 559697a..b9a0a56 100644 --- a/Model/BreezeThemeDetection.php +++ b/Model/BreezeThemeDetection.php @@ -13,6 +13,8 @@ class BreezeThemeDetection extends AbstractThemeDetection implements BreezeThemeDetectionInterface { /** + * Get module name + * * @return string */ public function getThemeModuleName(): string @@ -21,6 +23,8 @@ public function getThemeModuleName(): string } /** + * Get theme name + * * @return string */ public function getThemeName(): string diff --git a/Model/Config.php b/Model/Config.php index de27ce2..5df6682 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -4,6 +4,8 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Model; use Magento\Framework\App\Config\ScopeConfigInterface; @@ -14,16 +16,16 @@ class Config /** * Receive Notifications */ - const XML_PATH_RECEIVE_PRODUCT_UPDATES = 'mfextension/notification/update'; - const XML_PATH_RECEIVE_SPECIAL_OFFERS = 'mfextension/notification/offer'; - const XML_PATH_RECEIVE_NEWS = 'mfextension/notification/news'; - const XML_PATH_RECEIVE_TIPS_AND_TRICKS = 'mfextension/notification/tip_trick'; - const XML_PATH_RECEIVE_GENERAL_INFORMATION = 'mfextension/notification/general'; + public const XML_PATH_RECEIVE_PRODUCT_UPDATES = 'mfextension/notification/update'; + public const XML_PATH_RECEIVE_SPECIAL_OFFERS = 'mfextension/notification/offer'; + public const XML_PATH_RECEIVE_NEWS = 'mfextension/notification/news'; + public const XML_PATH_RECEIVE_TIPS_AND_TRICKS = 'mfextension/notification/tip_trick'; + public const XML_PATH_RECEIVE_GENERAL_INFORMATION = 'mfextension/notification/general'; /** * Display Menu */ - const XML_PATH_MENU_ENABLED = 'mfextension/menu/display'; + public const XML_PATH_MENU_ENABLED = 'mfextension/menu/display'; /** * @var ScopeConfigInterface @@ -32,6 +34,7 @@ class Config /** * Config constructor. + * * @param ScopeConfigInterface $scopeConfig */ public function __construct( @@ -43,7 +46,7 @@ public function __construct( /** * Receive Product Updates * - * @param null $storeId + * @param mixed $storeId * @return string */ public function receiveProductUpdates($storeId = null) @@ -57,7 +60,7 @@ public function receiveProductUpdates($storeId = null) /** * Receive Special Offers * - * @param null $storeId + * @param mixed $storeId * @return string */ public function receiveSpecialOffers($storeId = null) @@ -71,7 +74,7 @@ public function receiveSpecialOffers($storeId = null) /** * Receive News * - * @param null $storeId + * @param mixed $storeId * @return string */ public function receiveNews($storeId = null) @@ -85,7 +88,7 @@ public function receiveNews($storeId = null) /** * Receive Tips & Tricks * - * @param null $storeId + * @param mixed $storeId * @return string */ public function receiveTipsAndTricks($storeId = null) @@ -99,7 +102,7 @@ public function receiveTipsAndTricks($storeId = null) /** * Receive General Information * - * @param null $storeId + * @param mixed $storeId * @return string */ public function receiveGeneralInformation($storeId = null) @@ -113,7 +116,7 @@ public function receiveGeneralInformation($storeId = null) /** * Receive Notifications * - * @param null $storeId + * @param mixed $storeId * @return array */ public function receiveNotifications($storeId = null) @@ -130,7 +133,7 @@ public function receiveNotifications($storeId = null) /** * Display Menu * - * @param null $storeId + * @param mixed $storeId * @return string */ public function menuEnabled($storeId = null) @@ -145,7 +148,7 @@ public function menuEnabled($storeId = null) * Retrieve store config value * * @param string $path - * @param null $storeId + * @param mixed $storeId * @return mixed */ public function getConfig($path, $storeId = null) diff --git a/Model/GetCategoryByProduct.php b/Model/GetCategoryByProduct.php index 5738648..f2efe95 100644 --- a/Model/GetCategoryByProduct.php +++ b/Model/GetCategoryByProduct.php @@ -10,6 +10,7 @@ use Magefan\Community\Api\GetCategoryByProductInterface; use Magento\Catalog\Api\CategoryRepositoryInterface; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Store\Model\StoreManagerInterface; class GetCategoryByProduct implements GetCategoryByProductInterface @@ -31,6 +32,7 @@ class GetCategoryByProduct implements GetCategoryByProductInterface /** * GetModuleVersion constructor. + * * @param CategoryRepositoryInterface $categoryRepository * @param StoreManagerInterface $storeManager */ @@ -43,9 +45,12 @@ public function __construct( } /** + * Get categories by product + * * @param mixed $product * @param mixed $storeId * @returnmixed + * @throws NoSuchEntityException */ public function execute($product, $storeId = null) { @@ -80,7 +85,6 @@ public function execute($product, $storeId = null) } } - return $this->productCategory[$key] ?: null; } } diff --git a/Model/GetModuleInfo.php b/Model/GetModuleInfo.php index 87c68da..3262f86 100644 --- a/Model/GetModuleInfo.php +++ b/Model/GetModuleInfo.php @@ -12,11 +12,12 @@ use Magento\Framework\HTTP\Client\Curl; use Magento\Framework\App\CacheInterface; use Magefan\Community\Api\GetModuleInfoInterface; +use Psr\Log\LoggerInterface; class GetModuleInfo implements GetModuleInfoInterface { - const CACHE_KEY = 'magefan_product_versions_extended_json'; - const CACHE_LIFETIME = 43200; + public const CACHE_KEY = 'magefan_product_versions_extended_json'; + public const CACHE_LIFETIME = 43200; /** * @var Curl @@ -33,20 +34,30 @@ class GetModuleInfo implements GetModuleInfoInterface */ private $modulesInfo; + /** + * @var LoggerInterface + */ + private $logger; + /** * @param Curl $curl * @param CacheInterface $cache + * @param LoggerInterface $logger */ public function __construct( Curl $curl, - CacheInterface $cache + CacheInterface $cache, + LoggerInterface $logger ) { $this->curl = $curl; $this->cache = $cache; + $this->logger = $logger; } /** - * @param $moduleName + * Get data by module + * + * @param mixed $moduleName * @return array|DataObject|mixed */ public function execute($moduleName = null) @@ -66,6 +77,8 @@ public function execute($moduleName = null) } /** + * Get extension info + * * @return array */ public function getModulesInfo() @@ -87,6 +100,8 @@ public function getModulesInfo() } /** + * Load data + * * @return array */ private function load(): array @@ -106,13 +121,15 @@ private function load(): array $data = json_decode($response, true); } } catch (\Exception $e) { - + $this->logger->error($e->getMessage()); } return $data; } /** + * Get cached data + * * @return array */ private function loadFromCache(): array diff --git a/Model/GetModuleVersion.php b/Model/GetModuleVersion.php index 4e5f587..9fb9631 100644 --- a/Model/GetModuleVersion.php +++ b/Model/GetModuleVersion.php @@ -43,6 +43,7 @@ class GetModuleVersion implements GetModuleVersionInterface /** * GetModuleVersion constructor. + * * @param SerializerInterface $serializer * @param File $file * @param Reader $moduleReader @@ -61,6 +62,8 @@ public function __construct( } /** + * Get module version + * * @param string $moduleName * @return string */ diff --git a/Model/GetParentProductIds.php b/Model/GetParentProductIds.php index fb83e78..7578ac1 100644 --- a/Model/GetParentProductIds.php +++ b/Model/GetParentProductIds.php @@ -10,6 +10,7 @@ use Magefan\Community\Api\GetParentProductIdsInterface; use Magento\Framework\App\ResourceConnection; +use Magento\Framework\DB\Adapter\AdapterInterface; class GetParentProductIds implements GetParentProductIdsInterface { @@ -19,11 +20,10 @@ class GetParentProductIds implements GetParentProductIdsInterface protected $resourceConnection; /** - * @var \Magento\Framework\DB\Adapter\AdapterInterface + * @var AdapterInterface */ private $connection; - /** * GetParentProductIds constructor. * @param ResourceConnection $resourceConnection @@ -36,6 +36,8 @@ public function __construct( } /** + * Get parent product ids + * * @param array $productIds * @return array */ diff --git a/Model/GetWebsitesMap.php b/Model/GetWebsitesMap.php index 3aa0ecb..55d8f0b 100644 --- a/Model/GetWebsitesMap.php +++ b/Model/GetWebsitesMap.php @@ -19,12 +19,13 @@ class GetWebsitesMap implements GetWebsitesMapInterface private $storeManager; /** - * @var + * @var array */ private $websitesMap; /** * GetWebsitesMap constructor. + * * @param StoreManagerInterface $storeManager */ public function __construct( @@ -34,6 +35,8 @@ public function __construct( } /** + * Get websites + * * @return array */ public function execute(): array diff --git a/Model/HyvaThemeDetection.php b/Model/HyvaThemeDetection.php index c0228c7..82db939 100644 --- a/Model/HyvaThemeDetection.php +++ b/Model/HyvaThemeDetection.php @@ -13,6 +13,8 @@ class HyvaThemeDetection extends AbstractThemeDetection implements HyvaThemeDetectionInterface { /** + * Get hyva theme name + * * @return string */ public function getThemeModuleName(): string @@ -21,6 +23,8 @@ public function getThemeModuleName(): string } /** + * Gte theme name + * * @return string */ public function getThemeName(): string diff --git a/Model/Magento/Framework/Mail/Template/TransportBuilder.php b/Model/Magento/Framework/Mail/Template/TransportBuilder.php index e51c3ff..a212882 100644 --- a/Model/Magento/Framework/Mail/Template/TransportBuilder.php +++ b/Model/Magento/Framework/Mail/Template/TransportBuilder.php @@ -31,63 +31,54 @@ class TransportBuilder { /** - * Template Identifier * * @var string */ protected $templateIdentifier; /** - * Template Model * * @var string */ protected $templateModel; /** - * Template Variables * * @var array */ protected $templateVars; /** - * Template Options * * @var array */ protected $templateOptions; /** - * Mail Transport * * @var TransportInterface */ protected $transport; /** - * Template Factory * * @var FactoryInterface */ protected $templateFactory; /** - * Object Manager * * @var ObjectManagerInterface */ protected $objectManager; /** - * Message * * @var MessageInterface */ protected $message; /** - * Sender resolver * * @var SenderResolverInterface */ @@ -347,11 +338,13 @@ public function getTransport() } /** + * Add attachment + * * @param string $content * @param string $name * @param string $type - * @param $encoding - * @param $disposition + * @param mixed $encoding + * @param mixed $disposition * @return $this */ public function addAttachment(string $content, string $name, string $type, $encoding = null, $disposition = null) @@ -368,6 +361,8 @@ public function addAttachment(string $content, string $name, string $type, $enco } /** + * Prepare attachment + * * @return array */ private function getLaminasParts() @@ -389,6 +384,8 @@ private function getLaminasParts() } /** + * Prepare symfony parts + * * @return array */ private function getSymfonyParts() @@ -396,7 +393,11 @@ private function getSymfonyParts() $parts = []; foreach ($this->attachments as $attachmentData) { - $attachment = new \Symfony\Component\Mime\Part\DataPart($attachmentData['content'], $attachmentData['name'], $attachmentData['type']); + $attachment = new \Symfony\Component\Mime\Part\DataPart( + $attachmentData['content'], + $attachmentData['name'], + $attachmentData['type'] + ); $parts[] = $attachment; } @@ -473,10 +474,12 @@ protected function prepareMessage() ['parts' => $parts] ); + // phpcs:disable Magento2.Functions.DiscouragedFunction $this->messageData['subject'] = html_entity_decode( (string)$template->getSubject(), ENT_QUOTES ); + // phpcs:enable Magento2.Functions.DiscouragedFunction $this->message = $this->emailMessageInterfaceFactory->create($this->messageData); @@ -486,12 +489,16 @@ protected function prepareMessage() } /** + * Add symfony attachments + * * @param array $attachmentParts * @return void */ private function addSymfonyAttachment(array $attachmentParts): void { - if ($this->message instanceof \Magento\Framework\Mail\EmailMessage && method_exists($this->message, 'getSymfonyMessage')) { + if ($this->message instanceof \Magento\Framework\Mail\EmailMessage && + method_exists($this->message, 'getSymfonyMessage') + ) { $symfonyEmail = $this->message->getSymfonyMessage(); // Decode the original HTML body (quoted-printable) @@ -535,6 +542,8 @@ private function addAddressByType(string $addressType, $email, ?string $name = n } /** + * Check if current magento is 2.4.8 + * * @return bool */ private function isMagentoVersionLte248(): bool diff --git a/Model/Magento/Product/CollectionOptimizedForSqlValidator.php b/Model/Magento/Product/CollectionOptimizedForSqlValidator.php index f715b21..9895a5d 100644 --- a/Model/Magento/Product/CollectionOptimizedForSqlValidator.php +++ b/Model/Magento/Product/CollectionOptimizedForSqlValidator.php @@ -11,7 +11,10 @@ class CollectionOptimizedForSqlValidator extends \Magento\Catalog\Model\ResourceModel\Product\Collection { /** - * Prevent collect of attribute values in Magento\Rule\Model\Condition\Product\AbstractProduct::collectValidatedAttributes() since it is not used in SQL validator + * Prevent collect of attribute values in + * Magento\Rule\Model\Condition\Product\AbstractProduct::collectValidatedAttributes() + * since it is not used in SQL validator + * * @param string $attribute attribute code * @return array */ diff --git a/Model/Magento/Rule/Model/Condition/Sql/Builder.php b/Model/Magento/Rule/Model/Condition/Sql/Builder.php index b7ba215..66ad919 100644 --- a/Model/Magento/Rule/Model/Condition/Sql/Builder.php +++ b/Model/Magento/Rule/Model/Condition/Sql/Builder.php @@ -8,6 +8,7 @@ namespace Magefan\Community\Model\Magento\Rule\Model\Condition\Sql; +use Magento\Framework\Exception\LocalizedException; use Magento\Rule\Model\Condition\AbstractCondition; use Magento\Eav\Api\AttributeRepositoryInterface; use Magento\Eav\Model\Entity\Collection\AbstractCollection; @@ -18,8 +19,8 @@ class Builder extends \Magento\Rule\Model\Condition\Sql\Builder { - const UNDEFINED_OPERATOR = '<=>'; - const IS_OPERATOR = '=='; + private const UNDEFINED_OPERATOR = '<=>'; + private const IS_OPERATOR = '=='; /** * @var array @@ -39,6 +40,12 @@ class Builder extends \Magento\Rule\Model\Condition\Sql\Builder */ private $attributeRepository; + /** + * Construct + * + * @param ExpressionFactory $expressionFactory + * @param AttributeRepositoryInterface $attributeRepository + */ public function __construct( ExpressionFactory $expressionFactory, AttributeRepositoryInterface $attributeRepository @@ -47,6 +54,14 @@ public function __construct( $this->attributeRepository = $attributeRepository; } + /** + * Add attachment to collection + * + * @param AbstractCollection $collection + * @param Combine $combine + * @return void + * @throws LocalizedException + */ public function attachConditionToCollection( AbstractCollection $collection, Combine $combine @@ -63,7 +78,7 @@ public function attachConditionToCollection( * @param string $value * @param bool $isDefaultStoreUsed * @return string - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ protected function _getMappedSqlCondition( AbstractCondition $condition, @@ -76,7 +91,7 @@ protected function _getMappedSqlCondition( if (empty($argument)) { return (string) $this->_expressionFactory->create(['expression' => '1 = -1']); } elseif (preg_match('/[^a-z0-9\-_\.\`]/i', $argument) > 0 && !$argument instanceof \Zend_Db_Expr) { - throw new \Magento\Framework\Exception\LocalizedException(__('Invalid field')); + throw new LocalizedException(__('Invalid field')); } if (self::UNDEFINED_OPERATOR === $condition->getOperatorForValidate()) { @@ -87,7 +102,7 @@ protected function _getMappedSqlCondition( $conditionOperator = $condition->getOperatorForValidate(); if (!isset($this->_conditionOperatorMap[$conditionOperator])) { - throw new \Magento\Framework\Exception\LocalizedException(__('Unknown condition operator')); + throw new LocalizedException(__('Unknown condition operator')); } $defaultValue = $this->getDefaultValue($this->collectionCopy, $condition->getAttribute()); @@ -153,6 +168,8 @@ protected function _getMappedSqlCondition( } /** + * Get default value + * * @param AbstractCollection $collection * @param string $attributeCode * @return int|string @@ -172,6 +189,8 @@ private function getDefaultValue(AbstractCollection $collection, string $attribu } /** + * Is default value available for attribute + * * @param string $attributeCode * @return bool */ diff --git a/Model/Section.php b/Model/Section.php index 79064aa..9a46574 100644 --- a/Model/Section.php +++ b/Model/Section.php @@ -4,6 +4,8 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Model; use Magento\Framework\App\Config\ScopeConfigInterface; @@ -14,32 +16,32 @@ * Class Section * @package Magefan\Community\Model */ +// @codingStandardsIgnoreLine final class Section { - const MODULE = 'mfmodule'; + public const MODULE = 'mfmodule'; - const ENABLED = 'enabled'; + public const ENABLED = 'enabled'; - const KEY = 'key'; + public const KEY = 'key'; - const TYPE = 'mftype'; + public const TYPE = 'mftype'; - const ACTIVE = 'mfactive'; + public const ACTIVE = 'mfactive'; /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface + * @var ScopeConfigInterface */ private $scopeConfig; /** - * @var \Magefan\Community\Model\GetModuleVersion + * @var GetModuleVersion */ private $getModuleVersion; /** - * @var \Magefan\Community\Model\HyvaThemeDetection + * @var HyvaThemeDetection */ - private $hyvaThemeDetection; /** @@ -57,12 +59,12 @@ final class Section */ protected $metadata; - + // @codingStandardsIgnoreStart /** * @param ScopeConfigInterface $scopeConfig * @param ProductMetadataInterface $metadata - * @param \Magefan\Community\Model\GetModuleVersion $getModuleVersion - * @param \Magefan\Community\Model\HyvaThemeDetection $hyvaThemeDetection + * @param GetModuleVersion $getModuleVersion + * @param HyvaThemeDetection $hyvaThemeDetection * @param $name * @param $key */ @@ -83,6 +85,8 @@ final public function __construct( } /** + * Check if enabled + * * @return bool */ final public function isEnabled() @@ -91,6 +95,8 @@ final public function isEnabled() } /** + * Get module name + * * @param false $e * @return false|string */ @@ -108,6 +114,8 @@ final public function getModuleName($e = false) } /** + * Get module + * * @param false $e * @return false|string */ @@ -137,6 +145,8 @@ final public function getModule($e = false) } /** + * Get type + * * @return bool */ final public function getType() @@ -147,6 +157,8 @@ final public function getType() } /** + * Get key + * * @return string */ final public function getKey() @@ -159,6 +171,8 @@ final public function getKey() } /** + * Get name + * * @return string */ final public function getName() @@ -167,8 +181,9 @@ final public function getName() } /** + * Validate data + * * @param $data - * @param null $k * @return bool */ final public function validate($data) @@ -189,8 +204,11 @@ final public function validate($data) return false; } + // @codingStandardsIgnoreEnd /** + * Validate + * * @param string $id * @param string $k * @return bool @@ -206,6 +224,8 @@ private function validateIDK($id, $k) } /** + * Get config + * * @param string $field * @return mixed */ diff --git a/Model/Section/Info.php b/Model/Section/Info.php index 109c091..687fc1f 100644 --- a/Model/Section/Info.php +++ b/Model/Section/Info.php @@ -4,6 +4,8 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Model\Section; use Magento\Framework\App\ProductMetadataInterface; @@ -15,6 +17,7 @@ * Class Section Info * @package Magefan\Community\Model */ +// @codingStandardsIgnoreLine final class Info { /** @@ -37,8 +40,10 @@ final class Info */ private $modelModuleVersion; + // @codingStandardsIgnoreStart /** * Info constructor. + * * @param ProductMetadataInterface $metadata * @param StoreManagerInterface $storeManager * @param Curl $curl @@ -55,8 +60,12 @@ final public function __construct( $this->curl = $curl; $this->modelModuleVersion = $modelModuleVersion; } + // @codingStandardsIgnoreEnd + // @codingStandardsIgnoreStart /** + * Load by curl + * * @param array $sections * @return bool|mixed */ @@ -84,8 +93,11 @@ final public function load(array $sections) return false; } } + // @codingStandardsIgnoreEnd /** + * Get sections config + * * @param array $sections * @return array */ diff --git a/Model/SetLinvFlag.php b/Model/SetLinvFlag.php index 732198b..81a8d8d 100644 --- a/Model/SetLinvFlag.php +++ b/Model/SetLinvFlag.php @@ -38,16 +38,24 @@ public function __construct( } /** - * @param $module - * @param $value - * @param $errorMessage + * Set flag + * + * @param string $module + * @param string $value + * @param string $errorMessage * @return void */ public function execute($module, $value, $errorMessage = '') { $path = $module . '/g'.'en'.'er'.'al'.'/'; - $this->configWriter->save($path . 'l'.'in'.'v', $value, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0); - $this->configWriter->save($path . 'l'.'in'.'v'.'_'.'error_me'.'ss'.'ag'.'e', $errorMessage, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0); + $scopeDefault = ScopeConfigInterface::SCOPE_TYPE_DEFAULT; + $this->configWriter->save($path . 'l'.'in'.'v', $value, $scopeDefault, 0); + $this->configWriter->save( + $path . 'l'.'in'.'v'.'_'.'error_me'.'ss'.'ag'.'e', + $errorMessage, + $scopeDefault, + 0 + ); $this->cacheTypeList->cleanType(Config::TYPE_IDENTIFIER); } } diff --git a/Model/UrlChecker.php b/Model/UrlChecker.php index 264cad3..ac1a2a1 100644 --- a/Model/UrlChecker.php +++ b/Model/UrlChecker.php @@ -4,6 +4,8 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Model; /* @@ -11,7 +13,11 @@ */ class UrlChecker { + // @codingStandardsIgnoreStart /** + * Show url + * + * @param string $url * @return bool */ final public static function showUrl($url) @@ -31,4 +37,5 @@ final public static function showUrl($url) return (false === strpos($url, 'mag' . 'ento')) && !is_numeric($part); } + // @codingStandardsIgnoreEnd } diff --git a/Model/View/Helper/SecureHtmlRenderer.php b/Model/View/Helper/SecureHtmlRenderer.php index 22f2643..60c2aef 100644 --- a/Model/View/Helper/SecureHtmlRenderer.php +++ b/Model/View/Helper/SecureHtmlRenderer.php @@ -37,6 +37,8 @@ public function __construct( } /** + * Render tag + * * @param string $tagName * @param array $attributes * @param string|null $content @@ -51,7 +53,12 @@ public function renderTag( ) { $version = $this->productMetadata->getVersion(); if (version_compare($version, '2.4.0', ">")) { - return $this->objectManager->get(\Magento\Framework\View\Helper\SecureHtmlRenderer::class)->renderTag($tagName, $attributes, $content, $textContent); + return $this->objectManager->get(\Magento\Framework\View\Helper\SecureHtmlRenderer::class)->renderTag( + $tagName, + $attributes, + $content, + $textContent + ); } else { $attrs = []; if ($attributes) { diff --git a/Observer/ConfigObserver.php b/Observer/ConfigObserver.php index e162816..d506057 100644 --- a/Observer/ConfigObserver.php +++ b/Observer/ConfigObserver.php @@ -4,8 +4,11 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Observer; +use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; use Magefan\Community\Model\SectionFactory; use Magefan\Community\Model\Section\Info; @@ -44,8 +47,10 @@ class ConfigObserver implements ObserverInterface */ private $config; + // @codingStandardsIgnoreStart /** * ConfigObserver constructor. + * * @param SectionFactory $sectionFactory * @param Info $info * @param ManagerInterface $messageManager @@ -65,11 +70,15 @@ final public function __construct( $this->setLinvFlag = $setLinvFlag; $this->config = $config; } + // @codingStandardsIgnoreEnd + // @codingStandardsIgnoreStart /** - * @param \Magento\Framework\Event\Observer $observer + * Check config + * + * @param Observer $observer */ - final public function execute(\Magento\Framework\Event\Observer $observer) + final public function execute(Observer $observer) { $request = $observer->getEvent()->getRequest(); $groups = $request->getParam('groups'); @@ -133,4 +142,5 @@ final public function execute(\Magento\Framework\Event\Observer $observer) $this->setLinvFlag->execute($section->getName(), 0, $errorMessage); } } + // @codingStandardsIgnoreEnd } diff --git a/Observer/PredispathAdminActionControllerObserver.php b/Observer/PredispathAdminActionControllerObserver.php index 7dad012..7968b9b 100644 --- a/Observer/PredispathAdminActionControllerObserver.php +++ b/Observer/PredispathAdminActionControllerObserver.php @@ -4,8 +4,13 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Observer; +use Magefan\Community\Model\AdminNotificationFeedFactory; +use Magento\Backend\Model\Auth\Session; +use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; /** @@ -14,22 +19,22 @@ class PredispathAdminActionControllerObserver implements ObserverInterface { /** - * @var \Magefan\Community\Model\AdminNotificationFeedFactory + * @var AdminNotificationFeedFactory */ protected $feedFactory; /** - * @var \Magento\Backend\Model\Auth\Session + * @var Session */ protected $backendAuthSession; /** - * @param \Magefan\Community\Model\AdminNotificationFeedFactory $feedFactory - * @param \Magento\Backend\Model\Auth\Session $backendAuthSession + * @param AdminNotificationFeedFactory $feedFactory + * @param Session $backendAuthSession */ public function __construct( - \Magefan\Community\Model\AdminNotificationFeedFactory $feedFactory, - \Magento\Backend\Model\Auth\Session $backendAuthSession + AdminNotificationFeedFactory $feedFactory, + Session $backendAuthSession ) { $this->feedFactory = $feedFactory; $this->backendAuthSession = $backendAuthSession; @@ -38,11 +43,11 @@ public function __construct( /** * Predispath admin action controller * - * @param \Magento\Framework\Event\Observer $observer + * @param Observer $observer * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function execute(\Magento\Framework\Event\Observer $observer) + public function execute(Observer $observer) { if ($this->backendAuthSession->isLoggedIn()) { $feedModel = $this->feedFactory->create(); diff --git a/Plugin/Magento/Backend/Model/Menu/BuilderPlugin.php b/Plugin/Magento/Backend/Model/Menu/BuilderPlugin.php index 4a04a88..586d521 100644 --- a/Plugin/Magento/Backend/Model/Menu/BuilderPlugin.php +++ b/Plugin/Magento/Backend/Model/Menu/BuilderPlugin.php @@ -4,6 +4,8 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + namespace Magefan\Community\Plugin\Magento\Backend\Model\Menu; use Magento\Backend\Model\Menu\Builder; @@ -76,9 +78,11 @@ public function __construct( } /** + * Add custom data to result + * * @param Builder $subject * @param Menu $menu - * @param $result + * @param Menu $result * @return mixed $result */ public function afterGetResult(Builder $subject, Menu $menu, $result) @@ -152,7 +156,9 @@ public function afterGetResult(Builder $subject, Menu $menu, $result) } /** - * @param $moduleName + * Ge config by module name + * + * @param string $moduleName * @return mixed|null */ private function getConfigSections($moduleName) @@ -169,6 +175,7 @@ private function getConfigSections($moduleName) foreach ($tabs as $tab) { if (in_array($tab->getId(), ['magefan', 'mf_extensions_list'])) { + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $sections = array_merge($sections, $tab->getData()['children']); } } @@ -188,7 +195,9 @@ private function getConfigSections($moduleName) } /** - * @param $resource + * Get module by resource + * + * @param string $resource * @return string */ private function getModuleNameByResource($resource) @@ -200,9 +209,11 @@ private function getModuleNameByResource($resource) } /** - * @param $menu - * @param $items - * @param $parentId + * Create menu item + * + * @param Menu $menu + * @param array $items + * @param int $parentId */ private function createMenuItem($menu, $items, $parentId) { @@ -282,7 +293,9 @@ private function createMenuItem($menu, $items, $parentId) } /** - * @param $items + * Add sub menu item + * + * @param array $items * @return array */ private function getSubItem($items) @@ -297,6 +310,7 @@ private function getSubItem($items) $subItems[] = $item; } } elseif (!empty($item['sub_menu'])) { + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $subItems = array_merge($subItems, $this->getSubItem($item['sub_menu'])); } } diff --git a/Plugin/Magento/Framework/View/TemplateEngine/Php.php b/Plugin/Magento/Framework/View/TemplateEngine/Php.php index a50e8d1..dcfa3bf 100644 --- a/Plugin/Magento/Framework/View/TemplateEngine/Php.php +++ b/Plugin/Magento/Framework/View/TemplateEngine/Php.php @@ -1,4 +1,9 @@ mfHyvaThemeDetection = $mfHyvaThemeDetection; $this->mfBreezeThemeDetection = $mfBreezeThemeDetection; } + // @codingStandardsIgnoreEnd /** + * Add custom data + * * @param \Magento\Framework\View\TemplateEngine\Php $subject - * @param \Magento\Framework\View\Element\BlockInterface $block - * @param $fileName + * @param BlockInterface $block + * @param string $fileName * @param array $dictionary * @return array */ public function beforeRender( \Magento\Framework\View\TemplateEngine\Php $subject, - \Magento\Framework\View\Element\BlockInterface $block, + BlockInterface $block, $fileName, array $dictionary = [] ) { diff --git a/Setup/Patch/Data/UpdateWelcomeBlogPost.php b/Setup/Patch/Data/UpdateWelcomeBlogPost.php index 2f5dc1a..2c3194c 100644 --- a/Setup/Patch/Data/UpdateWelcomeBlogPost.php +++ b/Setup/Patch/Data/UpdateWelcomeBlogPost.php @@ -3,6 +3,9 @@ * Copyright © Magefan (support@magefan.com). All rights reserved. * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ + +declare(strict_types=1); + namespace Magefan\Community\Setup\Patch\Data; use Magento\Framework\Setup\Patch\DataPatchInterface; @@ -25,13 +28,14 @@ public function __construct( } /** - * {@inheritdoc} + * Replace text + * + * @return void */ public function apply() { $this->moduleDataSetup->getConnection()->startSetup(); - $connection = $this->moduleDataSetup->getConnection(); $tableName = $this->moduleDataSetup->getTable('magefan_blog_post'); @@ -88,7 +92,9 @@ public function apply() } /** - * {@inheritdoc} + * Get patch dependency's + * + * @return array|string[] */ public static function getDependencies() { @@ -96,7 +102,9 @@ public static function getDependencies() } /** - * {@inheritdoc} + * Get patch alias + * + * @return array|string[] */ public function getAliases() { diff --git a/view/adminhtml/templates/hyvathemechecker.phtml b/view/adminhtml/templates/hyvathemechecker.phtml index fd99e43..91baae2 100644 --- a/view/adminhtml/templates/hyvathemechecker.phtml +++ b/view/adminhtml/templates/hyvathemechecker.phtml @@ -9,25 +9,33 @@ + getWitchModuleIsInstalled()) { ?>
- escapeHtml(__('It looks like you are using the Hyva theme, ' . + escapeHtml(__('It looks like you are using the Hyva theme, ' . 'but the Hyva Magefan extensions for Hyva compatibility are not installed. ' . - 'Please install these packages for the proper functioning of the modules on the Hyva theme. Run the CLI commands:')) ?> + 'Please install these packages for the proper functioning of the modules on the Hyva theme. ' . + 'Run the CLI commands:')) ?>
$packageName) { - $commands .= 'composer require hyva-themes/magento2-compat-module-fallback' . PHP_EOL; - $commands .= 'composer require ' . $block->escapeHtml($packageName) . PHP_EOL; - $commands .= 'bin/magento setup:upgrade' . PHP_EOL; - $commands .= 'bin/magento setup:di:compile' . PHP_EOL; - $commands .= 'bin/magento setup:static-content:deploy' . PHP_EOL; - } + foreach ($items as $name => $packageName) { + $commands .= 'composer require hyva-themes/magento2-compat-module-fallback' . PHP_EOL; + $commands .= 'composer require ' . $escaper->escapeHtml($packageName) . PHP_EOL; + $commands .= 'bin/magento setup:upgrade' . PHP_EOL; + $commands .= 'bin/magento setup:di:compile' . PHP_EOL; + $commands .= 'bin/magento setup:static-content:deploy' . PHP_EOL; + } ?>

                 
diff --git a/view/adminhtml/templates/linv.phtml b/view/adminhtml/templates/linv.phtml index 1de7be8..960f897 100644 --- a/view/adminhtml/templates/linv.phtml +++ b/view/adminhtml/templates/linv.phtml @@ -9,9 +9,15 @@ * Help template * * @var $block \Magefan\Community\Block\Adminhtml\Linv + * @var $escaper \Magento\Framework\Escaper */ $disabledItems = $block->getItems(); $messages = $block->getMessages(); + +if (!isset($escaper)) { + /* Compatability fix for old Magento versions */ + $escaper = $block; +} ?>
@@ -22,10 +28,14 @@ $messages = $block->getMessages();
    $name) { ?> +
  • - Magefan escapeHtml($result = preg_replace('/([A-Z])/', ' $1', $name)); ?>: + Magefan + escapeHtml($result); ?>: - escapeHtml($messages[$name]) ?> + escapeHtml($messages[$name]) ?> @@ -34,7 +44,9 @@ $messages = $block->getMessages(); $message) { ?>
  • - escapeHtml( preg_replace('/([A-Z])/', ' $1', $name)) .': ' .$block->escapeQuote($message) ?> + escapeHtml( + preg_replace('/([A-Z])/', ' $1', $name) + ) .': ' .$escaper->escapeQuote($message) ?>
diff --git a/view/adminhtml/templates/vendors.phtml b/view/adminhtml/templates/vendors.phtml index f1cda27..e46acef 100644 --- a/view/adminhtml/templates/vendors.phtml +++ b/view/adminhtml/templates/vendors.phtml @@ -4,20 +4,46 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ ?> - + +
-

escapeHtml(__('Extension Vendors')) ?>

+

escapeHtml(__('Extension Vendors')) ?>

- - Magefan + + Magefan

Magefan

- Magefan is an eCommerce agency delivering top-notch extensions for Magento 2. We help eCommerce projects solve problems and reach their business goals faster.
+ Magefan is an eCommerce agency delivering top-notch extensions for Magento 2. We help eCommerce projects + solve problems and reach their business goals faster.
Magefan - eCommerce solutions you can trust.
- - escapeHtml('Read More') ?> + + escapeHtml('Read More') ?>

@@ -30,4 +56,4 @@ margin-top:0.8rem; max-width: 209px; } - \ No newline at end of file + diff --git a/view/adminhtml/web/css/source/_module.less b/view/adminhtml/web/css/source/_module.less index f2a8738..71ba1ab 100644 --- a/view/adminhtml/web/css/source/_module.less +++ b/view/adminhtml/web/css/source/_module.less @@ -1,5 +1,5 @@ +// phpcs:ignoreFile .admin__menu { - // Magefan Community Menu Lvl-0 #menu-magefan-community-elements { &._show { diff --git a/view/base/templates/js/isCustomerConsentProvided.phtml b/view/base/templates/js/isCustomerConsentProvided.phtml index 7128442..5a4496b 100644 --- a/view/base/templates/js/isCustomerConsentProvided.phtml +++ b/view/base/templates/js/isCustomerConsentProvided.phtml @@ -11,10 +11,10 @@ */ ?> getLayout()->createBlock(\Magefan\Community\Block\JsScript::class) ->setMethod('getCookie') diff --git a/view/base/templates/js/objToUrlParams.phtml b/view/base/templates/js/objToUrlParams.phtml index 6845ad8..9cd5c38 100644 --- a/view/base/templates/js/objToUrlParams.phtml +++ b/view/base/templates/js/objToUrlParams.phtml @@ -12,7 +12,7 @@ ?> `[${a}]`).join(\'\')}=${value}`)'; - ?> +?> Date: Mon, 3 Nov 2025 12:06:51 +0200 Subject: [PATCH 2/5] add strict type --- registration.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/registration.php b/registration.php index fc6a458..259d24f 100644 --- a/registration.php +++ b/registration.php @@ -4,6 +4,8 @@ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ +declare(strict_types=1); + \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Magefan_Community', From 764954328d551cc03d63c1d94ed88123a427aed4 Mon Sep 17 00:00:00 2001 From: Ihor M Date: Tue, 4 Nov 2025 13:06:32 +0200 Subject: [PATCH 3/5] revert throw to try block --- Controller/Adminhtml/Actions.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Controller/Adminhtml/Actions.php b/Controller/Adminhtml/Actions.php index 63ed550..d6976e6 100644 --- a/Controller/Adminhtml/Actions.php +++ b/Controller/Adminhtml/Actions.php @@ -155,13 +155,15 @@ protected function _newAction() */ public function _editAction() { - $model = $this->_getModel(); - $id = $this->getRequest()->getParam('id'); - if (!$model->getId() && $id) { - throw new Exception("Item is not longer exist.", 1); - } - try { + $model = $this->_getModel(); + $id = $this->getRequest()->getParam('id'); + if (!$model->getId() && $id) { + // phpcs:disable + throw new Exception("Item is not longer exist.", 1); + // phpcs:disable + } + $this->_getRegistry()->register('current_model', $model); $this->_view->loadLayout(); @@ -311,12 +313,14 @@ public function _saveAction() */ protected function _duplicateAction() { - $originModel = $this->_getModel(); - if (!$originModel->getId()) { - throw new Exception("Item is not longer exist.", 1); - } - try { + $originModel = $this->_getModel(); + if (!$originModel->getId()) { + // phpcs:disable + throw new Exception("Item is not longer exist.", 1); + // phpcs:disable + } + $model = $originModel->duplicate(); $this->messageManager->addSuccess(__('%1 has been duplicated.', $model->getOwnTitle())); From b9ba0d9c6bd537d00176f0696843f2f0211e8eb7 Mon Sep 17 00:00:00 2001 From: Ihor M Date: Wed, 5 Nov 2025 12:48:03 +0200 Subject: [PATCH 4/5] change null comparation position --- Controller/Adminhtml/Actions.php | 8 ++++---- Model/AdminNotificationFeed.php | 2 +- Model/GetWebsitesMap.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Controller/Adminhtml/Actions.php b/Controller/Adminhtml/Actions.php index d6976e6..87af5d4 100644 --- a/Controller/Adminhtml/Actions.php +++ b/Controller/Adminhtml/Actions.php @@ -439,11 +439,11 @@ protected function _massStatusAction() $status = $this->getRequest()->getParam('status'); $statusFieldName = $this->_statusField; - if ($status === null) { + if (null === $status) { throw new Exception(__('Parameter "Status" missing in request data.')); } - if ($statusFieldName === null) { + if (null === $statusFieldName) { throw new Exception(__('Status Field Name is not specified.')); } @@ -529,7 +529,7 @@ protected function filterParams($data) */ protected function _getRegistry() { - if ($this->_coreRegistry === null) { + if (null === $this->_coreRegistry) { $this->_coreRegistry = $this->_objectManager->get(Registry::class); } return $this->_coreRegistry; @@ -554,7 +554,7 @@ protected function _isAllowed() */ protected function _getModel($load = true) { - if ($this->_model === null) { + if (null === $this->_model) { $this->_model = $this->_objectManager->create($this->_modelClass); $id = (int)$this->getRequest()->getParam($this->_idKey); diff --git a/Model/AdminNotificationFeed.php b/Model/AdminNotificationFeed.php index 1e74d48..35c3d19 100644 --- a/Model/AdminNotificationFeed.php +++ b/Model/AdminNotificationFeed.php @@ -153,7 +153,7 @@ protected function _construct() */ public function getFeedUrl() { - if ($this->_feedUrl === null) { + if (null === $this->_feedUrl) { $this->_feedUrl = 'https://mage'.'fan' .'.c'.'om/community/notifications'.'/'.'feed/'; } diff --git a/Model/GetWebsitesMap.php b/Model/GetWebsitesMap.php index 55d8f0b..24cc58b 100644 --- a/Model/GetWebsitesMap.php +++ b/Model/GetWebsitesMap.php @@ -41,12 +41,12 @@ public function __construct( */ public function execute(): array { - if ($this->websitesMap === null) { + if (null === $this->websitesMap) { $this->websitesMap = []; $websites = $this->storeManager->getWebsites(); foreach ($websites as $website) { // Continue if website has no store to be able to create catalog rule for website without store - if ($website->getDefaultStore() === null) { + if (null === $website->getDefaultStore()) { continue; } $this->websitesMap[$website->getId()] = $website->getDefaultStore()->getId(); From c739bb6523660a41a04615cd1e112d50bde4637c Mon Sep 17 00:00:00 2001 From: Ihor M Date: Thu, 6 Nov 2025 13:59:36 +0200 Subject: [PATCH 5/5] update image attributes --- Block/Adminhtml/System/Config/Form/Info.php | 4 +++- view/adminhtml/templates/vendors.phtml | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Block/Adminhtml/System/Config/Form/Info.php b/Block/Adminhtml/System/Config/Form/Info.php index af1dcb3..29b9141 100755 --- a/Block/Adminhtml/System/Config/Form/Info.php +++ b/Block/Adminhtml/System/Config/Form/Info.php @@ -133,7 +133,9 @@ public function render(AbstractElement $element) >
diff --git a/view/adminhtml/templates/vendors.phtml b/view/adminhtml/templates/vendors.phtml index e46acef..23062a4 100644 --- a/view/adminhtml/templates/vendors.phtml +++ b/view/adminhtml/templates/vendors.phtml @@ -31,6 +31,8 @@ if (!isset($escaper)) { $block->getViewFileUrl('Magefan_Community::images/magefan-logo.png') ) ?>" alt="Magefan" + width="1256" + height="268" />

Magefan