Skip to content

Commit bc3b2ea

Browse files
committed
Fix PHP CS issues
1 parent 6c3112f commit bc3b2ea

57 files changed

Lines changed: 324 additions & 256 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.php_cs.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"php":"7.4.5","version":"2.16.3:v2.16.3#83baf823a33a1cbd5416c8626935cf3f843c10b0","indent":" ","lineEnding":"\n","rules":{"array_syntax":{"syntax":"short"},"binary_operator_spaces":true,"blank_line_after_opening_tag":true,"blank_line_before_statement":{"statements":["return"]},"braces":{"allow_single_line_closure":true},"cast_spaces":{"space":"single"},"class_attributes_separation":{"elements":["method"]},"class_definition":{"single_line":true},"concat_space":{"spacing":"one"},"declare_equal_normalize":true,"function_typehint_space":true,"include":true,"increment_style":true,"lowercase_cast":true,"lowercase_static_reference":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":true,"native_function_casing":true,"native_function_type_declaration_casing":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["curly_brace_block","extra","parenthesis_brace_block","square_brace_block","throw","use"]},"no_leading_import_slash":true,"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":true,"no_unneeded_curly_braces":{"namespaces":true},"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"no_whitespace_in_blank_line":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"ordered_imports":true,"php_unit_fqcn_annotation":true,"phpdoc_align":{"align":"left"},"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag":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_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,"return_type_declaration":true,"semicolon_after_instruction":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_class_element_per_statement":true,"single_line_comment_style":{"comment_types":["hash"]},"single_line_throw":true,"single_quote":true,"single_trait_insert_per_statement":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"ternary_operator_spaces":true,"trailing_comma_in_multiline_array":true,"trim_array_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":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,"visibility_required":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":{"tests\/index.php":2657184305,"tests\/phpstan\/index.php":2657184305,"index.php":2657184305,"classes\/Form\/index.php":2657184305,"classes\/Form\/ConfigurationForm.php":2607320067,"classes\/index.php":2657184305,"classes\/GoogleAnalyticsTools.php":2454784637,"classes\/Hook\/HookDisplayHome.php":1331593200,"classes\/Hook\/index.php":2657184305,"classes\/Hook\/HookDisplayFooter.php":1377542451,"classes\/Hook\/HookDisplayBackOfficeHeader.php":62664555,"classes\/Hook\/HookDisplayHeader.php":3203340892,"classes\/Hook\/HookDisplayOrderConfirmation.php":3859977258,"classes\/Hook\/HookActionCarrierProcess.php":4156494746,"classes\/Hook\/HookActionProductCancel.php":1967332341,"classes\/Hook\/HookInterface.php":2350618434,"classes\/Hook\/HookDisplayFooterProduct.php":1036485983,"classes\/Hook\/HookActionCartSave.php":4029443709,"classes\/Handler\/index.php":2657184305,"classes\/Handler\/ModuleHandler.php":1844907236,"classes\/Handler\/GanalyticsJsHandler.php":2208903929,"classes\/Handler\/GanalyticsDataHandler.php":2818967706,"classes\/Database\/index.php":2657184305,"classes\/Database\/Uninstall.php":3995443079,"classes\/Database\/Install.php":1503889843,"classes\/Wrapper\/index.php":2657184305,"classes\/Wrapper\/ProductWrapper.php":3918842904,"classes\/Wrapper\/WrapperInterface.php":3165813164,"classes\/Wrapper\/OrderWrapper.php":2236500015,"classes\/Repository\/GanalyticsDataRepository.php":693896051,"classes\/Repository\/index.php":2657184305,"classes\/Repository\/GanalyticsRepository.php":396338050,"classes\/Repository\/CarrierRepository.php":595599245,"ps_googleanalytics.php":2237291875,"views\/img\/index.php":2657184305,"views\/index.php":2657184305,"views\/css\/index.php":2657184305,"views\/js\/index.php":2657184305,"views\/templates\/hook\/index.php":2657184305,"views\/templates\/index.php":2657184305,"views\/templates\/admin\/index.php":2657184305,"upgrade\/install-3.1.0.php":4083663024,"upgrade\/index.php":2657184305,"translations\/index.php":2657184305,"translations\/fr.php":4138912457,"translations\/de.php":4244071240,"translations\/it.php":1991868331,"translations\/es.php":2343815783,"translations\/en.php":1605709074,"controllers\/index.php":2657184305,"controllers\/front\/index.php":2657184305,"controllers\/front\/ajax.php":1920076942,"controllers\/admin\/index.php":2657184305,"controllers\/admin\/AdminGanalyticsAjax.php":1493758573}}

.php_cs.dist

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
$config = new PrestaShop\CodingStandards\CsFixer\Config();
4+
5+
$config
6+
->setUsingCache(true)
7+
->getFinder()
8+
->in(__DIR__)
9+
->exclude('vendor');
10+
11+
return $config;

.prettyci.composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require-dev": {
3+
"prestashop/php-dev-tools": "^2.0"
4+
}
5+
}

classes/Database/Install.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public function __construct(\Ps_Googleanalytics $module)
4343
*/
4444
public function installTables()
4545
{
46-
$sql = array();
46+
$sql = [];
4747

48-
$sql[] = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'ganalytics` (
48+
$sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'ganalytics` (
4949
`id_google_analytics` int(11) NOT NULL AUTO_INCREMENT,
5050
`id_order` int(11) NOT NULL,
5151
`id_customer` int(10) NOT NULL,
@@ -55,14 +55,14 @@ public function installTables()
5555
PRIMARY KEY (`id_google_analytics`),
5656
KEY `id_order` (`id_order`),
5757
KEY `sent` (`sent`)
58-
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 AUTO_INCREMENT=1';
58+
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8 AUTO_INCREMENT=1';
5959

60-
$sql[] = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'ganalytics_data` (
60+
$sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'ganalytics_data` (
6161
`id_cart` int(11) NOT NULL,
6262
`id_shop` int(11) NOT NULL,
6363
`data` TEXT DEFAULT NULL,
6464
PRIMARY KEY (`id_cart`)
65-
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8';
65+
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
6666

6767
foreach ($sql as $query) {
6868
if (!\Db::getInstance()->execute($query)) {

classes/Database/Uninstall.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class Uninstall
2929
*/
3030
public function uninstallTables()
3131
{
32-
$sql[] = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'ganalytics`';
33-
$sql[] = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'ganalytics_data`';
32+
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'ganalytics`';
33+
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'ganalytics_data`';
3434

3535
foreach ($sql as $query) {
3636
if (!\Db::getInstance()->execute($query)) {

classes/Database/index.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
1818
* International Registered Trademark & Property of PrestaShop SA
1919
*/
20-
2120
header('Expires: Mon, 26 Jul 1998 05:00:00 GMT');
22-
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
21+
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
2322

2423
header('Cache-Control: no-store, no-cache, must-revalidate');
2524
header('Cache-Control: post-check=0, pre-check=0', false);

classes/Form/ConfigurationForm.php

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class ConfigurationForm
2424
{
2525
private $module;
2626

27-
public function __construct(\Ps_Googleanalytics $module) {
27+
public function __construct(\Ps_Googleanalytics $module)
28+
{
2829
$this->module = $module;
2930
}
3031

@@ -39,15 +40,15 @@ public function generate()
3940
$is_multistore_active = \Shop::isFeatureActive();
4041

4142
// Get default language
42-
$default_lang = (int)\Configuration::get('PS_LANG_DEFAULT');
43+
$default_lang = (int) \Configuration::get('PS_LANG_DEFAULT');
4344

4445
$helper = new \HelperForm();
4546

4647
// Module, token and currentIndex
4748
$helper->module = $this->module;
4849
$helper->name_controller = $this->module->name;
4950
$helper->token = \Tools::getAdminTokenLite('AdminModules');
50-
$helper->currentIndex = \AdminController::$currentIndex.'&configure=' . $this->module->name;
51+
$helper->currentIndex = \AdminController::$currentIndex . '&configure=' . $this->module->name;
5152

5253
// Language
5354
$helper->default_form_language = $default_lang;
@@ -58,92 +59,91 @@ public function generate()
5859
$helper->show_toolbar = true; // false -> remove toolbar
5960
$helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen.
6061
$helper->submit_action = 'submit' . $this->module->name;
61-
$helper->toolbar_btn = array(
62-
'save' =>
63-
array(
62+
$helper->toolbar_btn = [
63+
'save' => [
6464
'desc' => $this->module->l('Save'),
65-
'href' => \AdminController::$currentIndex.'&configure=' . $this->module->name.'&save' . $this->module->name.
66-
'&token='.\Tools::getAdminTokenLite('AdminModules'),
67-
),
68-
'back' => array(
69-
'href' => \AdminController::$currentIndex.'&token='.\Tools::getAdminTokenLite('AdminModules'),
70-
'desc' => $this->module->l('Back to list')
71-
)
72-
);
73-
74-
$fields_form = array();
65+
'href' => \AdminController::$currentIndex . '&configure=' . $this->module->name . '&save' . $this->module->name .
66+
'&token=' . \Tools::getAdminTokenLite('AdminModules'),
67+
],
68+
'back' => [
69+
'href' => \AdminController::$currentIndex . '&token=' . \Tools::getAdminTokenLite('AdminModules'),
70+
'desc' => $this->module->l('Back to list'),
71+
],
72+
];
73+
74+
$fields_form = [];
7575
// Init Fields form array
76-
$fields_form[0]['form'] = array(
77-
'legend' => array(
76+
$fields_form[0]['form'] = [
77+
'legend' => [
7878
'title' => $this->module->l('Settings'),
79-
),
80-
'input' => array(
81-
array(
79+
],
80+
'input' => [
81+
[
8282
'type' => 'text',
8383
'label' => $this->module->l('Google Analytics Tracking ID'),
8484
'name' => 'GA_ACCOUNT_ID',
8585
'size' => 20,
8686
'required' => true,
87-
'hint' => $this->module->l('This information is available in your Google Analytics account')
88-
),
89-
array(
87+
'hint' => $this->module->l('This information is available in your Google Analytics account'),
88+
],
89+
[
9090
'type' => 'switch',
9191
'label' => $this->module->l('Enable User ID tracking'),
9292
'name' => 'GA_USERID_ENABLED',
93-
'values' => array(
94-
array(
93+
'values' => [
94+
[
9595
'id' => 'ga_userid_enabled',
9696
'value' => 1,
97-
'label' => $this->module->l('Enabled')
98-
),
99-
array(
97+
'label' => $this->module->l('Enabled'),
98+
],
99+
[
100100
'id' => 'ga_userid_disabled',
101101
'value' => 0,
102-
'label' => $this->module->l('Disabled')
103-
))
104-
),
105-
array(
102+
'label' => $this->module->l('Disabled'),
103+
], ],
104+
],
105+
[
106106
'type' => 'switch',
107107
'label' => $this->module->l('Anonymize IP'),
108108
'name' => 'GA_ANONYMIZE_ENABLED',
109109
'hint' => $this->module->l('Use this option to anonymize the visitor’s IP to comply with data privacy laws in some countries'),
110-
'values' => array(
111-
array(
110+
'values' => [
111+
[
112112
'id' => 'ga_anonymize_enabled',
113113
'value' => 1,
114-
'label' => $this->module->l('Enabled')
115-
),
116-
array(
114+
'label' => $this->module->l('Enabled'),
115+
],
116+
[
117117
'id' => 'ga_anonymize_disabled',
118118
'value' => 0,
119-
'label' => $this->module->l('Disabled')
120-
),
121-
),
122-
),
123-
),
124-
'submit' => array(
119+
'label' => $this->module->l('Disabled'),
120+
],
121+
],
122+
],
123+
],
124+
'submit' => [
125125
'title' => $this->module->l('Save'),
126-
)
127-
);
126+
],
127+
];
128128

129129
if ($is_multistore_active) {
130-
$fields_form[0]['form']['input'][] = array(
130+
$fields_form[0]['form']['input'][] = [
131131
'type' => 'switch',
132132
'label' => $this->module->l('Enable Cross-Domain tracking'),
133133
'name' => 'GA_CROSSDOMAIN_ENABLED',
134-
'values' => array(
135-
array(
134+
'values' => [
135+
[
136136
'id' => 'ga_crossdomain_enabled',
137137
'value' => 1,
138-
'label' => $this->module->l('Enabled')
139-
),
140-
array(
138+
'label' => $this->module->l('Enabled'),
139+
],
140+
[
141141
'id' => 'ga_crossdomain_disabled',
142142
'value' => 0,
143-
'label' => $this->module->l('Disabled')
144-
)
145-
)
146-
);
143+
'label' => $this->module->l('Disabled'),
144+
],
145+
],
146+
];
147147
}
148148

149149
// Load current value

classes/Form/index.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
1818
* International Registered Trademark & Property of PrestaShop SA
1919
*/
20-
2120
header('Expires: Mon, 26 Jul 1998 05:00:00 GMT');
22-
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
21+
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
2322

2423
header('Cache-Control: no-store, no-cache, must-revalidate');
2524
header('Cache-Control: post-check=0, pre-check=0', false);

classes/GoogleAnalyticsTools.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ public function addTransaction($products, $order)
5555

5656
$js = '';
5757
foreach ($products as $product) {
58-
$js .= 'MBG.add('.json_encode($product).');';
58+
$js .= 'MBG.add(' . json_encode($product) . ');';
5959
}
6060

61-
return $js.'MBG.addTransaction('.json_encode($order).');';
61+
return $js . 'MBG.addTransaction(' . json_encode($order) . ');';
6262
}
6363

6464
/**
@@ -76,7 +76,7 @@ public function addProductImpression($products)
7676

7777
$js = '';
7878
foreach ($products as $product) {
79-
$js .= 'MBG.add('.json_encode($product).",'',true);";
79+
$js .= 'MBG.add(' . json_encode($product) . ",'',true);";
8080
}
8181

8282
return $js;
@@ -97,7 +97,7 @@ public function addProductClick($products)
9797

9898
$js = '';
9999
foreach ($products as $product) {
100-
$js .= 'MBG.addProductClick('.json_encode($product).');';
100+
$js .= 'MBG.addProductClick(' . json_encode($product) . ');';
101101
}
102102

103103
return $js;
@@ -118,7 +118,7 @@ public function addProductClickByHttpReferal($products)
118118

119119
$js = '';
120120
foreach ($products as $product) {
121-
$js .= 'MBG.addProductClickByHttpReferal('.json_encode($product).');';
121+
$js .= 'MBG.addProductClickByHttpReferal(' . json_encode($product) . ');';
122122
}
123123

124124
return $js;
@@ -139,7 +139,7 @@ public function addProductFromCheckout($products)
139139

140140
$js = '';
141141
foreach ($products as $product) {
142-
$js .= 'MBG.add('.json_encode($product).');';
142+
$js .= 'MBG.add(' . json_encode($product) . ');';
143143
}
144144

145145
return $js;

classes/Handler/GanalyticsDataHandler.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class GanalyticsDataHandler
3636
*/
3737
public function __construct($cartId, $shopId)
3838
{
39-
$this->ganalyticsDataRepository = new GanalyticsDataRepository;
40-
$this->cartId = (int) $cartId;
41-
$this->shopId = (int) $shopId;
39+
$this->ganalyticsDataRepository = new GanalyticsDataRepository();
40+
$this->cartId = (int) $cartId;
41+
$this->shopId = (int) $shopId;
4242
}
4343

4444
/**
@@ -90,7 +90,7 @@ private function readData()
9090
);
9191

9292
if (false === $dataRetuned) {
93-
return array();
93+
return [];
9494
}
9595

9696
return json_decode($dataRetuned, true);
@@ -111,7 +111,7 @@ private function appendData($data)
111111
);
112112

113113
if (false === $dataRetuned) {
114-
$newData = array($data);
114+
$newData = [$data];
115115
} else {
116116
$newData = json_decode($dataRetuned, true);
117117
$newData[] = $data;

0 commit comments

Comments
 (0)