Skip to content

Commit 09acc8c

Browse files
PLGMAG2V2-765: Add PHPStan tests (#723)
1 parent 85a39d7 commit 09acc8c

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

.github/workflows/phpstan.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Magento 2 PHPStan
2+
on: [push]
3+
4+
jobs:
5+
phpstan:
6+
name: PHPStan
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Setup PHP
10+
uses: shivammathur/setup-php@v2
11+
with:
12+
php-version: '7.4'
13+
env:
14+
COMPOSER_AUTH_JSON: |
15+
{
16+
"http-basic": {
17+
"repo.magento.com": {
18+
"username": "${{ secrets.MAGENTO_MARKETPLACE_USERNAME }}",
19+
"password": "${{ secrets.MAGENTO_MARKETPLACE_PASSWORD }}"
20+
}
21+
}
22+
}
23+
- uses: actions/checkout@v4
24+
- name: Create composer project
25+
run: composer create-project --no-install --no-interaction --no-plugins --repository-url=https://repo-magento-mirror.fooman.co.nz/ magento/project-community-edition:2.4.5-p8 /home/runner/work/magento
26+
- name: Add composer plugins
27+
working-directory: /home/runner/work/magento
28+
run: composer config --no-plugins allow-plugins true
29+
- name: Add module to composer
30+
working-directory: /home/runner/work/magento
31+
run: composer require multisafepay/magento2-core --no-update --no-interaction
32+
- name: Install composer dependencies
33+
working-directory: /home/runner/work/magento
34+
run: composer install --no-interaction
35+
- name: Move repository content
36+
run: cp -r -f ${{ github.workspace }}/* /home/runner/work/magento/vendor/multisafepay/magento2-core
37+
- name: Run PHPStan
38+
working-directory: /home/runner/work/magento
39+
run: vendor/bin/phpstan analyse -c vendor/multisafepay/magento2-core/phpstan.neon --error-format github

Model/Method/GenericAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ public function canSale(): bool
585585
/**
586586
* @inheritdoc
587587
*/
588-
public function sale(InfoInterface $payment, float $amount): ?ResultInterface
588+
public function sale(InfoInterface $payment, float $amount)
589589
{
590590
$this->executeCommand(
591591
'sale',

phpstan.neon

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
parameters:
2+
level: 0
3+
errorFormat: github
4+
paths:
5+
- .
6+
excludePaths:
7+
- etc
8+
- Test
9+
- view
10+
- Model/Api/Builder/OrderRequestBuilder/ShoppingCartBuilder/CustomTotalBuilder.php
11+
- Util/ThirdPartyPluginsUtil.php
12+
ignoreErrors:
13+
- '#Parameter \$\w+ of method [a-zA-Z0-9\\_]+::__construct\(\) has invalid type .*Factory.*#'
14+
- '#Method [a-zA-Z0-9\\_]+::getExtensionAttributes\(\) has invalid return type .*OrderPaymentExtension.*#'

0 commit comments

Comments
 (0)