Skip to content

Commit cb6f406

Browse files
Improvement: Better PHPStan analysis
1 parent cc70022 commit cb6f406

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

.github/workflows/phpstan.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ jobs:
1414
MAGENTO_VERSION: 2.4.6-p4
1515
- PHP_VERSION: php83-fpm
1616
MAGENTO_VERSION: 2.4.7
17+
- PHP_VERSION: php83-fpm
18+
MAGENTO_VERSION: 2.4.7
19+
PHPSTAN_LEVEL: 2
20+
21+
name: PHP ${{ matrix.PHP_VERSION }} Magento ${{ matrix.MAGENTO_VERSION }}${{ matrix.PHPSTAN_LEVEL && format(' Level {0}', matrix.PHPSTAN_LEVEL) || '' }}
1722

1823
runs-on: ubuntu-latest
1924
steps:
@@ -35,4 +40,12 @@ jobs:
3540
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade && php bin/magento setup:di:compile"
3641

3742
- name: Run PHPStan
38-
run: docker exec magento-project-community-edition /bin/bash -c "./vendor/bin/phpstan analyse --no-progress -c /data/extensions/*/phpstan.neon /data/extensions"
43+
continue-on-error: ${{ matrix.PHPSTAN_LEVEL == 2 }}
44+
run: |
45+
LEVEL_OPTION=""
46+
47+
if [ -n "${{ matrix.PHPSTAN_LEVEL }}" ]; then
48+
LEVEL_OPTION="--level=${{ matrix.PHPSTAN_LEVEL }}"
49+
fi
50+
51+
docker exec magento-project-community-edition /bin/bash -c "./vendor/bin/phpstan analyse --no-progress $LEVEL_OPTION -c /data/extensions/*/phpstan.neon /data/extensions"

phpstan-baseline.neon

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,46 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Method Mollie\\\\Payment\\\\Block\\\\Info\\\\Base\\:\\:getOrderId\\(\\) should return string but return statement is missing\\.$#"
4+
message: "#^Use service contracts to persist entities in favour of Magento\\\\SalesRule\\\\Model\\\\Coupon\\:\\:load\\(\\) method$#"
55
count: 1
6-
path: Block/Info/Base.php
6+
path: Helper/General.php
77

88
-
9-
message: "#^Method Mollie\\\\Payment\\\\Controller\\\\Checkout\\\\Process\\:\\:execute\\(\\) should return Magento\\\\Framework\\\\App\\\\ResponseInterface\\|Magento\\\\Framework\\\\Controller\\\\ResultInterface but return statement is missing\\.$#"
9+
message: "#^Use service contracts to persist entities in favour of Magento\\\\SalesRule\\\\Model\\\\Coupon\\:\\:save\\(\\) method$#"
1010
count: 1
11-
path: Controller/Checkout/Process.php
11+
path: Helper/General.php
1212

1313
-
14-
message: "#^Method Mollie\\\\Payment\\\\Controller\\\\Checkout\\\\Redirect\\:\\:execute\\(\\) should return Magento\\\\Framework\\\\App\\\\ResponseInterface\\|Magento\\\\Framework\\\\Controller\\\\ResultInterface but return statement is missing\\.$#"
14+
message: "#^Use service contracts to persist entities in favour of Magento\\\\Sales\\\\Model\\\\Order\\:\\:save\\(\\) method$#"
1515
count: 1
16-
path: Controller/Checkout/Redirect.php
16+
path: Model/Methods/Reorder.php
1717

1818
-
19-
message: "#^Method Mollie\\\\Payment\\\\Controller\\\\Checkout\\\\Restart\\:\\:execute\\(\\) should return Magento\\\\Framework\\\\App\\\\ResponseInterface\\|Magento\\\\Framework\\\\Controller\\\\ResultInterface but return statement is missing\\.$#"
19+
message: "#^Use service contracts to persist entities in favour of Mollie\\\\Payment\\\\Model\\\\OrderLines\\:\\:load\\(\\) method$#"
2020
count: 1
21-
path: Controller/Checkout/Restart.php
21+
path: Model/OrderLines.php
2222

2323
-
24-
message: "#^Method Mollie\\\\Payment\\\\Controller\\\\Checkout\\\\Success\\:\\:execute\\(\\) should return Magento\\\\Framework\\\\App\\\\ResponseInterface\\|Magento\\\\Framework\\\\Controller\\\\ResultInterface but return statement is missing\\.$#"
25-
count: 1
26-
path: Controller/Checkout/Success.php
24+
message: "#^Use service contracts to persist entities in favour of Mollie\\\\Payment\\\\Model\\\\OrderLines\\:\\:save\\(\\) method$#"
25+
count: 2
26+
path: Model/OrderLines.php
2727

2828
-
29-
message: "#^Method Mollie\\\\Payment\\\\Helper\\\\General\\:\\:getBanktransferDueDate\\(\\) should return string\\|false but return statement is missing\\.$#"
29+
message: "#^Use service contracts to persist entities in favour of Magento\\\\SalesRule\\\\Model\\\\Coupon\\:\\:load\\(\\) method$#"
3030
count: 1
31-
path: Helper/General.php
31+
path: Service/Order/CancelOrder.php
3232

3333
-
34-
message: "#^Method Mollie\\\\Payment\\\\Model\\\\Adminhtml\\\\Backend\\\\VerifiyPaymentFee\\:\\:beforeSave\\(\\) should return \\$this\\(Mollie\\\\Payment\\\\Model\\\\Adminhtml\\\\Backend\\\\VerifiyPaymentFee\\) but return statement is missing\\.$#"
34+
message: "#^Use service contracts to persist entities in favour of Magento\\\\SalesRule\\\\Model\\\\Coupon\\:\\:save\\(\\) method$#"
3535
count: 1
36-
path: Model/Adminhtml/Backend/VerifiyPaymentFee.php
36+
path: Service/Order/CancelOrder.php
3737

3838
-
39-
message: "#^Method Mollie\\\\Payment\\\\Model\\\\Methods\\\\Reorder\\:\\:initialize\\(\\) should return \\$this\\(Mollie\\\\Payment\\\\Model\\\\Methods\\\\Reorder\\) but return statement is missing\\.$#"
39+
message: "#^Use service contracts to persist entities in favour of Mollie\\\\Payment\\\\Model\\\\OrderLines\\:\\:save\\(\\) method$#"
4040
count: 1
41-
path: Model/Methods/Reorder.php
41+
path: Service/Order/Lines/Order.php
4242

4343
-
44-
message: "#^Method Mollie\\\\Payment\\\\Model\\\\Mollie\\:\\:createOrderRefund\\(\\) should return \\$this\\(Mollie\\\\Payment\\\\Model\\\\Mollie\\) but return statement is missing\\.$#"
44+
message: "#^Use service contracts to persist entities in favour of Magento\\\\Quote\\\\Model\\\\QuoteIdMask\\:\\:load\\(\\) method$#"
4545
count: 1
46-
path: Model/Mollie.php
47-
46+
path: Webapi/PaymentToken.php

phpstan.neon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,3 @@ parameters:
1414
- phtml
1515
excludePaths:
1616
- Test/*
17-
# These fail on Magento 2.2 and that's expected, these are only applicable on Magento 2.3 and higher.
18-
- Service/Order/Uncancel/OrderReservation.php

0 commit comments

Comments
 (0)