From 10b38eea0ae7f04b9b6cb268001c6a31834fe42d Mon Sep 17 00:00:00 2001 From: L3RAZ Date: Thu, 30 Jan 2025 15:24:58 +0200 Subject: [PATCH] Update phpstan level --- .github/workflows/php.yml | 15 +++++++++++-- tests/Unit/bootstrap.php | 2 +- tests/phpstan/bootstrap.php | 6 ++++++ tests/phpstan/phpstan-PS-9.neon | 38 +++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 tests/phpstan/bootstrap.php create mode 100644 tests/phpstan/phpstan-PS-9.neon diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 5892331ed..c337a3c2b 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -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 diff --git a/tests/Unit/bootstrap.php b/tests/Unit/bootstrap.php index f5a588baa..ec5e8adab 100644 --- a/tests/Unit/bootstrap.php +++ b/tests/Unit/bootstrap.php @@ -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'; diff --git a/tests/phpstan/bootstrap.php b/tests/phpstan/bootstrap.php new file mode 100644 index 000000000..ec5e8adab --- /dev/null +++ b/tests/phpstan/bootstrap.php @@ -0,0 +1,6 @@ +\|int given.#' + - '#Parameter \#1 \$id of class Customer constructor expects null, int\|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 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 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