Skip to content

Commit

Permalink
Update phpstan level
Browse files Browse the repository at this point in the history
  • Loading branch information
L3RAZ committed Jan 30, 2025
1 parent b9d1068 commit 10b38ee
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,20 @@ jobs:
- name: Pull PrestaShop files (Tag ${{ matrix.presta-versions }})
run: docker run -tid --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:${{ matrix.presta-versions }}

- name: Run PHPStan
run: docker run --rm --volumes-from temp-ps -v $PWD:/web/module -e _PS_ROOT_DIR_=/var/www/html --workdir=/web/module ghcr.io/phpstan/phpstan:latest-php8.1 analyse --configuration=/web/module/tests/phpstan/phpstan-PS-8.neon --error-format=github
- name: List contents of . for debugging
run: docker exec temp-ps ls -la .

- name: List contents of /modules for debugging
run: docker exec temp-ps ls -la /modules

- name: Copy working directory to temp-ps
run: docker cp $PWD temp-ps:/modules/ps_checkout/

- name: List contents of /var/www/html for debugging
run: docker exec temp-ps ls -la /var/www/html/modules/ps_checkout

- name: Run PHPStan
run: docker run --rm --volumes-from temp-ps -v $PWD:/var/www/html/modules/ps_checkout -e _PS_ROOT_DIR_=/var/www/html/ --workdir=/var/www/html/modules/ps_checkout ghcr.io/phpstan/phpstan:latest-php8.1 analyse --configuration=/var/www/html/modules/ps_checkout/tests/phpstan/phpstan-PS-9.neon --error-format=github --level=max --debug
phpunit:
name: PHPUnit
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

$rootDirectory = getenv('_PS_ROOT_DIR_') ?: __DIR__ . '/../../../../';
$projectDir = __DIR__ . '/../../';
//require_once $rootDirectory . 'config/config.inc.php';
require_once $rootDirectory . 'config/config.inc.php';
require_once $projectDir . 'vendor/autoload.php';
6 changes: 6 additions & 0 deletions tests/phpstan/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

$rootDirectory = getenv('_PS_ROOT_DIR_') ?: __DIR__ . '/../../../../';
$projectDir = __DIR__ . '/../../';
require_once $rootDirectory . 'config/config.inc.php';
require_once $projectDir . 'vendor/autoload.php';
38 changes: 38 additions & 0 deletions tests/phpstan/phpstan-PS-9.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
includes:
- %currentWorkingDirectory%/vendor/prestashop/php-dev-tools/phpstan/ps-module-extension.neon
parameters:
bootstrapFiles:
- ./bootstrap.php
paths:
# From PHPStan 0.12, paths to check are relative to the neon file
- ../../classes
- ../../controllers
- ../../src
- ../../ps_checkout.php
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- '#Cannot assign offset "merchant…" to string\|true.#'
- '#Property ModuleCore::\$version \(float\) does not accept string.#'
- '#Strict comparison using === between false and string will always evaluate to false.#'
- '#Call to function is_array\(\) with Currency will always evaluate to false.#'
- '#Parameter \#1 \$id of class Customer constructor expects null, bool\|int<1, max>\|int<min, -1> given.#'
- '#Parameter \#1 \$id of class Customer constructor expects null, int<min, -1>\|int<1, max> given.#'
- '#Parameter \#1 \$id of class Customer constructor expects null, int given.#'
- '#Parameter \#1 \$hook_name of method ModuleCore::registerHook\(\) expects string, array<int, string> given.#'
- '#Parameter \#6 \$idShop of method LinkCore::getModuleLink\(\) expects null, int given.#'
- '#Call to an undefined method\(\) AdminController|FrontController::getCheckoutProcess\(\).#'
- '#Parameter \#1 \$id_hook of method ModuleCore::updatePosition\(\) expects bool, int given.#'
- '#Property TabCore::\$name \(string\) does not accept array.#'
- '#Access to an undefined property PaymentModule::\$currentOrderReference.#'
- '#Property CustomerCore::\$passwd \(int\) does not accept bool\|string.#'
- '#Property CustomerCore::\$passwd \(int\) does not accept string.#'
- '#Parameter \#4 \$ssl of method LinkCore::getModuleLink\(\) expects null, true given.#'
- '#Parameter \#1 \$id of class Customer constructor expects null, int<1, max>\|int<min, -1> given.#'
- '#Property CustomerMessageCore::\$ip_address \(string\) does not accept int.#'
- '#Left side of \&\& is always true.#'
- '#Parameter \#7 \$currency_special of method PaymentModuleCore::validateOrder\(\) expects null, int given.#'
- '#Parameter \#9 \$secure_key of method PaymentModuleCore::validateOrder\(\) expects bool, string given.#'
- '#Property CustomerMessageCore::\$private \(int\) does not accept true.#'
- '#Parameter \#1 \$amount_paid of method OrderCore::addOrderPayment\(\) expects string, float\|int given.#'

level: 5

0 comments on commit 10b38ee

Please sign in to comment.