Skip to content

Commit 389150d

Browse files
committed
Improve PHPStan error handled
1 parent f43d588 commit 389150d

5 files changed

Lines changed: 8 additions & 12 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
vendor/
22
.php_cs.cache
3-
.prettyci.composer.json
3+
.prettyci.composer.json

.prettyci.composer.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

classes/Hook/HookActionCartSave.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
class HookActionCartSave implements HookInterface
2727
{
2828
private $module;
29+
30+
/**
31+
* @var \Context
32+
*/
2933
private $context;
3034

3135
public function __construct(\Ps_Googleanalytics $module, \Context $context)
@@ -58,7 +62,7 @@ public function run()
5862
];
5963

6064
$cartProducts = $this->context->cart->getProducts();
61-
if (isset($cartProducts) && count($cartProducts)) {
65+
if (!empty($cartProducts)) {
6266
foreach ($cartProducts as $cartProduct) {
6367
if ($cartProduct['id_product'] == \Tools::getValue('id_product')) {
6468
$addProduct = $cartProduct;

classes/Hook/HookActionProductCancel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public function run()
4848
$gaScripts .= 'MBG.add(' . json_encode(
4949
[
5050
'id' => empty($orderDetail->product_attribute_id) ? $orderDetail->product_id : $orderDetail->product_id . '-' . $orderDetail->product_attribute_id,
51-
'quantity' => $quantity, ]
52-
)
51+
'quantity' => $quantity,
52+
])
5353
. ');';
5454
}
5555

tests/phpstan/phpstan.neon

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ parameters:
1010
ignoreErrors:
1111
- '#Property Ps_Googleanalytics::\$version \(float\) does not accept string.#'
1212
- '#Strict comparison using === between false and Module will always evaluate to false.#'
13-
-
14-
message: '#Access to an undefined property object::\$shop.#'
15-
path: ../../classes/Hook/HookActionCartSave.php
1613
- '#PrestaShop.Module.Ps_Googleanalytics.Handler.ModuleHandler::uninstallModule\(\) calls parent::uninstall\(\) but PrestaShop.Module.Ps_Googleanalytics.Handler.ModuleHandler does not extend any class.#'
1714

1815
level: 5

0 commit comments

Comments
 (0)