diff --git a/.php_cs.cache b/.php_cs.cache new file mode 100644 index 0000000..ada1919 --- /dev/null +++ b/.php_cs.cache @@ -0,0 +1 @@ +{"php":"7.2.34-18+ubuntu18.04.1+deb.sury.org+1","version":"2.18.4-DEV:v2.18.4#06f764e3cb6d60822d8f5135205f9d32b5508a31","indent":" ","lineEnding":"\n","rules":{"array_syntax":{"syntax":"short"},"backtick_to_shell_exec":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["return"]},"braces":{"allow_single_line_anonymous_class_with_empty_body":true,"allow_single_line_closure":true},"cast_spaces":{"space":"single"},"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":{"single_line":true},"clean_namespace":true,"concat_space":{"spacing":"one"},"echo_tag_syntax":true,"fully_qualified_strict_types":true,"function_typehint_space":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"include":true,"increment_style":true,"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":true,"native_function_casing":true,"native_function_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use","use_trait"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","return","switch_case","yield","yield_from"]},"no_unneeded_curly_braces":{"namespaces":true},"no_unset_cast":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"ordered_imports":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":{"align":"left"},"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"semicolon_after_instruction":true,"single_class_element_per_statement":true,"single_line_comment_style":{"comment_types":["hash"]},"single_line_throw":true,"single_quote":true,"single_space_after_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline_array":true,"trim_array_spaces":true,"unary_operator_spaces":true,"visibility_required":true,"whitespace_after_comma_in_array":true,"blank_line_after_opening_tag":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"error_suppression":{"mute_deprecation_error":false,"noise_remaining_usages":false,"noise_remaining_usages_exclude":[]},"non_printable_character":true},"hashes":{"translations\/index.php":76070504,"views\/templates\/hook\/index.php":76070504,"views\/templates\/index.php":76070504,"views\/index.php":76070504,"index.php":76070504,"tests\/index.php":76070504,"tests\/phpstan\/index.php":76070504,"ps_featuredproducts.php":158169043}} \ No newline at end of file diff --git a/index.php b/index.php index a9b5c78..6028c7f 100644 --- a/index.php +++ b/index.php @@ -23,13 +23,12 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) * International Registered Trademark & Property of PrestaShop SA */ - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Location: ../'); -exit; \ No newline at end of file +exit; diff --git a/ps_featuredproducts.php b/ps_featuredproducts.php index dd9600e..ce10e64 100644 --- a/ps_featuredproducts.php +++ b/ps_featuredproducts.php @@ -23,17 +23,12 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) * International Registered Trademark & Property of PrestaShop SA */ - if (!defined('_PS_VERSION_')) { exit; } -use PrestaShop\PrestaShop\Core\Module\WidgetInterface; use PrestaShop\PrestaShop\Adapter\Category\CategoryProductSearchProvider; -use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever; -use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter; -use PrestaShop\PrestaShop\Core\Product\ProductListingPresenter; -use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever; +use PrestaShop\PrestaShop\Core\Module\WidgetInterface; use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext; use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery; use PrestaShop\PrestaShop\Core\Product\Search\SortOrder; @@ -57,8 +52,8 @@ public function __construct() $this->bootstrap = true; parent::__construct(); - $this->displayName = $this->trans('Featured products', array(), 'Modules.Featuredproducts.Admin'); - $this->description = $this->trans('Pick a category and highlight its items, enhance customer experience with a lively homepage.', array(), 'Modules.Featuredproducts.Admin'); + $this->displayName = $this->trans('Featured products', [], 'Modules.Featuredproducts.Admin'); + $this->description = $this->trans('Pick a category and highlight its items, enhance customer experience with a lively homepage.', [], 'Modules.Featuredproducts.Admin'); $this->templateFile = 'module:ps_featuredproducts/views/templates/hook/ps_featuredproducts.tpl'; } @@ -123,22 +118,22 @@ public function _clearCache($template, $cache_id = null, $compile_id = null) public function getContent() { $output = ''; - $errors = array(); + $errors = []; if (Tools::isSubmit('submitHomeFeatured')) { $nbr = Tools::getValue('HOME_FEATURED_NBR'); if (!Validate::isInt($nbr) || $nbr <= 0) { - $errors[] = $this->trans('The number of products is invalid. Please enter a positive number.', array(), 'Modules.Featuredproducts.Admin'); + $errors[] = $this->trans('The number of products is invalid. Please enter a positive number.', [], 'Modules.Featuredproducts.Admin'); } $cat = Tools::getValue('HOME_FEATURED_CAT'); if (!Validate::isInt($cat) || $cat <= 0) { - $errors[] = $this->trans('The category ID is invalid. Please choose an existing category ID.', array(), 'Modules.Featuredproducts.Admin'); + $errors[] = $this->trans('The category ID is invalid. Please choose an existing category ID.', [], 'Modules.Featuredproducts.Admin'); } $rand = Tools::getValue('HOME_FEATURED_RANDOMIZE'); if (!Validate::isBool($rand)) { - $errors[] = $this->trans('Invalid value for the "randomize" flag.', array(), 'Modules.Featuredproducts.Admin'); + $errors[] = $this->trans('Invalid value for the "randomize" flag.', [], 'Modules.Featuredproducts.Admin'); } if (isset($errors) && count($errors)) { $output = $this->displayError(implode('
', $errors)); @@ -149,65 +144,65 @@ public function getContent() $this->_clearCache('*'); - $output = $this->displayConfirmation($this->trans('The settings have been updated.', array(), 'Admin.Notifications.Success')); + $output = $this->displayConfirmation($this->trans('The settings have been updated.', [], 'Admin.Notifications.Success')); } } - return $output.$this->renderForm(); + return $output . $this->renderForm(); } public function renderForm() { - $fields_form = array( - 'form' => array( - 'legend' => array( - 'title' => $this->trans('Settings', array(), 'Admin.Global'), + $fields_form = [ + 'form' => [ + 'legend' => [ + 'title' => $this->trans('Settings', [], 'Admin.Global'), 'icon' => 'icon-cogs', - ), + ], - 'description' => $this->trans('To add products to your homepage, simply add them to the corresponding product category (default: "Home").', array(), 'Modules.Featuredproducts.Admin'), - 'input' => array( - array( + 'description' => $this->trans('To add products to your homepage, simply add them to the corresponding product category (default: "Home").', [], 'Modules.Featuredproducts.Admin'), + 'input' => [ + [ 'type' => 'text', - 'label' => $this->trans('Number of products to be displayed', array(), 'Modules.Featuredproducts.Admin'), + 'label' => $this->trans('Number of products to be displayed', [], 'Modules.Featuredproducts.Admin'), 'name' => 'HOME_FEATURED_NBR', 'class' => 'fixed-width-xs', - 'desc' => $this->trans('Set the number of products that you would like to display on homepage (default: 8).', array(), 'Modules.Featuredproducts.Admin'), - ), - array( + 'desc' => $this->trans('Set the number of products that you would like to display on homepage (default: 8).', [], 'Modules.Featuredproducts.Admin'), + ], + [ 'type' => 'categories', 'tree' => [ 'id' => 'home_featured_category', - 'selected_categories' => [ Configuration::get('HOME_FEATURED_CAT'), ], + 'selected_categories' => [Configuration::get('HOME_FEATURED_CAT')], ], - 'label' => $this->trans('Category from which to pick products to be displayed', array(), 'Modules.Featuredproducts.Admin'), + 'label' => $this->trans('Category from which to pick products to be displayed', [], 'Modules.Featuredproducts.Admin'), 'name' => 'HOME_FEATURED_CAT', - ), - array( + ], + [ 'type' => 'switch', - 'label' => $this->trans('Randomly display featured products', array(), 'Modules.Featuredproducts.Admin'), + 'label' => $this->trans('Randomly display featured products', [], 'Modules.Featuredproducts.Admin'), 'name' => 'HOME_FEATURED_RANDOMIZE', 'class' => 'fixed-width-xs', - 'desc' => $this->trans('Enable if you wish the products to be displayed randomly (default: no).', array(), 'Modules.Featuredproducts.Admin'), - 'values' => array( - array( + 'desc' => $this->trans('Enable if you wish the products to be displayed randomly (default: no).', [], 'Modules.Featuredproducts.Admin'), + 'values' => [ + [ 'id' => 'active_on', 'value' => 1, - 'label' => $this->trans('Yes', array(), 'Admin.Global'), - ), - array( + 'label' => $this->trans('Yes', [], 'Admin.Global'), + ], + [ 'id' => 'active_off', 'value' => 0, - 'label' => $this->trans('No', array(), 'Admin.Global'), - ), - ), - ), - ), - 'submit' => array( - 'title' => $this->trans('Save', array(), 'Admin.Actions'), - ), - ), - ); + 'label' => $this->trans('No', [], 'Admin.Global'), + ], + ], + ], + ], + 'submit' => [ + 'title' => $this->trans('Save', [], 'Admin.Actions'), + ], + ], + ]; $lang = new Language((int) Configuration::get('PS_LANG_DEFAULT')); @@ -218,24 +213,24 @@ public function renderForm() $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $helper->identifier = $this->identifier; $helper->submit_action = 'submitHomeFeatured'; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; + $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array( + $helper->tpl_vars = [ 'fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id, - ); + ]; - return $helper->generateForm(array($fields_form)); + return $helper->generateForm([$fields_form]); } public function getConfigFieldsValues() { - return array( + return [ 'HOME_FEATURED_NBR' => Tools::getValue('HOME_FEATURED_NBR', (int) Configuration::get('HOME_FEATURED_NBR')), 'HOME_FEATURED_CAT' => Tools::getValue('HOME_FEATURED_CAT', (int) Configuration::get('HOME_FEATURED_CAT')), 'HOME_FEATURED_RANDOMIZE' => Tools::getValue('HOME_FEATURED_RANDOMIZE', (bool) Configuration::get('HOME_FEATURED_RANDOMIZE')), - ); + ]; } public function renderWidget($hookName = null, array $configuration = []) @@ -258,11 +253,12 @@ public function getWidgetVariables($hookName = null, array $configuration = []) $products = $this->getProducts(); if (!empty($products)) { - return array( + return [ 'products' => $products, 'allProductsLink' => Context::getContext()->link->getCategoryLink($this->getConfigFieldsValues()['HOME_FEATURED_CAT']), - ); + ]; } + return false; } diff --git a/tests/index.php b/tests/index.php index a9b5c78..6028c7f 100644 --- a/tests/index.php +++ b/tests/index.php @@ -23,13 +23,12 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) * International Registered Trademark & Property of PrestaShop SA */ - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Location: ../'); -exit; \ No newline at end of file +exit; diff --git a/tests/phpstan/index.php b/tests/phpstan/index.php index a9b5c78..6028c7f 100644 --- a/tests/phpstan/index.php +++ b/tests/phpstan/index.php @@ -23,13 +23,12 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) * International Registered Trademark & Property of PrestaShop SA */ - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Location: ../'); -exit; \ No newline at end of file +exit; diff --git a/translations/index.php b/translations/index.php index a9b5c78..6028c7f 100644 --- a/translations/index.php +++ b/translations/index.php @@ -23,13 +23,12 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) * International Registered Trademark & Property of PrestaShop SA */ - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Location: ../'); -exit; \ No newline at end of file +exit; diff --git a/views/index.php b/views/index.php index a9b5c78..6028c7f 100644 --- a/views/index.php +++ b/views/index.php @@ -23,13 +23,12 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) * International Registered Trademark & Property of PrestaShop SA */ - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Location: ../'); -exit; \ No newline at end of file +exit; diff --git a/views/templates/hook/index.php b/views/templates/hook/index.php index a9b5c78..6028c7f 100644 --- a/views/templates/hook/index.php +++ b/views/templates/hook/index.php @@ -23,13 +23,12 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) * International Registered Trademark & Property of PrestaShop SA */ - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Location: ../'); -exit; \ No newline at end of file +exit; diff --git a/views/templates/index.php b/views/templates/index.php index a9b5c78..6028c7f 100644 --- a/views/templates/index.php +++ b/views/templates/index.php @@ -23,13 +23,12 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) * International Registered Trademark & Property of PrestaShop SA */ - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Location: ../'); -exit; \ No newline at end of file +exit;