From 0fd5c7755c50447bb736b59e2d7a8f94af64d81d Mon Sep 17 00:00:00 2001 From: mattgoud Date: Tue, 2 Jun 2026 18:10:26 +0200 Subject: [PATCH 1/8] CI: migrate PHPStan to PrestaShop/.github action Replace the Docker-based phpstan.sh approach with the shared PrestaShop/.github PHPStan action. The old approach was failing because the prestashop/prestashop:latest Docker image now exits immediately (due to entrypoint changes), causing "No such container: temp-ps" errors. - Add tests/php/phpstan/ with version-specific neon configs for 8.1.7, 8.2.x, 9.1.x and develop - Add prepend-constants.php for PS 9.x bootstrap constants - Replace single Docker-based phpstan job with two action-based jobs: phpstan-74 (PS 8.x, PHP 7.4-8.1) and phpstan (PS 9.x, PHP 8.1-8.5) - Remove tests/phpstan.sh (no longer needed) Fixes #ISSUE Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/php.yml | 143 ++++++++++++++---------- tests/php/phpstan/index.php | 8 ++ tests/php/phpstan/phpstan-8.1.7.neon | 5 + tests/php/phpstan/phpstan-8.2.x.neon | 5 + tests/php/phpstan/phpstan-9.1.x.neon | 5 + tests/php/phpstan/phpstan-develop.neon | 5 + tests/php/phpstan/phpstan.neon | 2 + tests/php/phpstan/prepend-constants.php | 11 ++ tests/phpstan.sh | 28 ----- 9 files changed, 128 insertions(+), 84 deletions(-) create mode 100644 tests/php/phpstan/index.php create mode 100644 tests/php/phpstan/phpstan-8.1.7.neon create mode 100644 tests/php/phpstan/phpstan-8.2.x.neon create mode 100644 tests/php/phpstan/phpstan-9.1.x.neon create mode 100644 tests/php/phpstan/phpstan-develop.neon create mode 100644 tests/php/phpstan/phpstan.neon create mode 100644 tests/php/phpstan/prepend-constants.php delete mode 100755 tests/phpstan.sh diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index af9213f..80c2c68 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -1,70 +1,101 @@ name: PHP tests on: [push, pull_request] jobs: - # Check there is no syntax errors in the project - php-linter: - name: PHP Syntax check 5.6 => 8.1 - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v5 + php-linter: + name: PHP Syntax check 7.2 => 8.5 + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 - - name: PHP syntax checker 5.6 - uses: prestashop/github-action-php-lint/5.6@master + - name: PHP syntax checker 7.2 + uses: prestashop/github-action-php-lint/7.2@master - - name: PHP syntax checker 7.2 - uses: prestashop/github-action-php-lint/7.2@master + - name: PHP syntax checker 7.4 + uses: prestashop/github-action-php-lint/7.4@master - - name: PHP syntax checker 7.3 - uses: prestashop/github-action-php-lint/7.3@master + - name: PHP syntax checker 8.0 + uses: prestashop/github-action-php-lint/8.0@master - - name: PHP syntax checker 7.4 - uses: prestashop/github-action-php-lint/7.4@master + - name: PHP syntax checker 8.5 + uses: prestashop/github-action-php-lint/8.5@master - - name: PHP syntax checker 8.0 - uses: prestashop/github-action-php-lint/8.0@master + # Check the PHP code follow the coding standards + php-cs-fixer: + name: PHP-CS-Fixer + runs-on: ubuntu-latest + steps: + - name: Run PHP-CS-Fixer + uses: PrestaShop/.github/.github/actions/php-ci/php-cs@master + with: + php-version: '7.4' - - name: PHP syntax checker 8.1 - uses: prestashop/github-action-php-lint/8.1@master + # Run PHPStan against the module (PHP 7.4 – 8.1) + phpstan-74: + name: PHPStan (PHP 7.4 - 8.1) + runs-on: ubuntu-latest + strategy: + matrix: + presta_version: ['8.1.7', '8.2.x'] + php_version: ['7.4', '8.1'] + fail-fast: false + env: + PHPRC: ${{ github.workspace }}/${{ github.event.repository.name }}/.phpstan-php-ini + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + path: ${{ github.event.repository.name }} - # Check the PHP code follow the coding standards - php-cs-fixer: - name: PHP-CS-Fixer - runs-on: ubuntu-latest - steps: - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' + - name: Prepare PHP env for PrestaShop 8 (define constants before any bootstrap) + run: | + mkdir -p ${{ github.event.repository.name }}/.phpstan-php-ini + { + echo "auto_prepend_file=$GITHUB_WORKSPACE/${{ github.event.repository.name }}/tests/php/phpstan/prepend-constants.php" + echo "memory_limit=512M" + } > ${{ github.event.repository.name }}/.phpstan-php-ini/php.ini - - name: Checkout - uses: actions/checkout@v5 + - name: Run PHPStan + uses: PrestaShop/.github/.github/actions/php-ci/phpstan@master + with: + php-version: ${{ matrix.php_version }} + presta-version: ${{ matrix.presta_version }} + module-name: ${{ github.event.repository.name }} + phpstan-level: '5' + phpstan-config: tests/php/phpstan/phpstan-${{ matrix.presta_version }}.neon + phpstan-version: '^0.12' + composer-version: '2.2.18' - - name: Install dependencies - run: composer install + # Run PHPStan against the module (PHP 8.1 – 8.5) + phpstan: + name: PHPStan (PHP 8.1 - 8.5) + runs-on: ubuntu-latest + strategy: + matrix: + presta_version: ['9.1.x', 'develop'] + php_version: ['8.1', '8.5'] + fail-fast: false + env: + PHPRC: ${{ github.workspace }}/${{ github.event.repository.name }}/.phpstan-php-ini + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + path: ${{ github.event.repository.name }} - - name: Run PHP-CS-Fixer - run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no --diff-format udiff + - name: Prepare PHP env for PrestaShop 9.1.x and later (define constants before any bootstrap) + run: | + mkdir -p ${{ github.event.repository.name }}/.phpstan-php-ini + { + echo "auto_prepend_file=$GITHUB_WORKSPACE/${{ github.event.repository.name }}/tests/php/phpstan/prepend-constants.php" + echo "memory_limit=512M" + } > ${{ github.event.repository.name }}/.phpstan-php-ini/php.ini - # Run PHPStan against the module and a PrestaShop release - phpstan: - name: PHPStan - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - presta-versions: ['1.7.6', '1.7.7', '1.7.8', 'latest'] - steps: - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - - - name: Checkout - uses: actions/checkout@v5 - - - run: composer install - - # Docker images prestashop/prestashop may be used, even if the shop remains uninstalled - - name: Execute PHPStan on PrestaShop (Tag ${{ matrix.presta-versions }}) - run: ./tests/phpstan.sh ${{ matrix.presta-versions }} + - name: Run PHPStan + uses: PrestaShop/.github/.github/actions/php-ci/phpstan@master + with: + php-version: ${{ matrix.php_version }} + presta-version: ${{ matrix.presta_version }} + module-name: ${{ github.event.repository.name }} + phpstan-level: '5' + phpstan-config: tests/php/phpstan/phpstan-${{ matrix.presta_version }}.neon diff --git a/tests/php/phpstan/index.php b/tests/php/phpstan/index.php new file mode 100644 index 0000000..30c3516 --- /dev/null +++ b/tests/php/phpstan/index.php @@ -0,0 +1,8 @@ + Date: Tue, 2 Jun 2026 18:39:12 +0200 Subject: [PATCH 2/8] CI: add ignoreErrors for pre-existing PHPStan issues on PS 8.x Suppress three pre-existing PHPStan errors exposed by the new 8.1.7/8.2.x analysis that were not caught by the old Docker-based 1.7.x checks. These should be addressed in a separate code-quality PR. Co-Authored-By: Claude Sonnet 4.6 --- tests/php/phpstan/phpstan-8.1.7.neon | 3 +++ tests/php/phpstan/phpstan-8.2.x.neon | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/php/phpstan/phpstan-8.1.7.neon b/tests/php/phpstan/phpstan-8.1.7.neon index a5ad764..1940ad2 100644 --- a/tests/php/phpstan/phpstan-8.1.7.neon +++ b/tests/php/phpstan/phpstan-8.1.7.neon @@ -3,3 +3,6 @@ includes: parameters: ignoreErrors: + - '#Property statsbestproducts::\$html is never read, only written\.#' + - '#Property ModuleGridCore::\$_direction \(string\) in isset\(\) is not nullable\.#' + - '#Offset .* does not exist on array\{avgPriceSold: string\}\.#' diff --git a/tests/php/phpstan/phpstan-8.2.x.neon b/tests/php/phpstan/phpstan-8.2.x.neon index a5ad764..1940ad2 100644 --- a/tests/php/phpstan/phpstan-8.2.x.neon +++ b/tests/php/phpstan/phpstan-8.2.x.neon @@ -3,3 +3,6 @@ includes: parameters: ignoreErrors: + - '#Property statsbestproducts::\$html is never read, only written\.#' + - '#Property ModuleGridCore::\$_direction \(string\) in isset\(\) is not nullable\.#' + - '#Offset .* does not exist on array\{avgPriceSold: string\}\.#' From a9f4097dd71200e4cbe693b0cdc662ec7d4f85af Mon Sep 17 00:00:00 2001 From: mattgoud Date: Tue, 2 Jun 2026 19:49:08 +0200 Subject: [PATCH 3/8] CI: fix php-cs-fixer and add ignoreErrors for PS 9.x PHPStan jobs - Add missing blank line after --- tests/php/phpstan/index.php | 1 + tests/php/phpstan/phpstan-9.1.x.neon | 2 ++ tests/php/phpstan/phpstan-develop.neon | 2 ++ 3 files changed, 5 insertions(+) diff --git a/tests/php/phpstan/index.php b/tests/php/phpstan/index.php index 30c3516..63eec81 100644 --- a/tests/php/phpstan/index.php +++ b/tests/php/phpstan/index.php @@ -1,4 +1,5 @@ Date: Mon, 8 Jun 2026 17:49:14 +0200 Subject: [PATCH 4/8] Align module on PrestaShop 8.2+ minimum (Epic #41648) Drop the 8.1.7 target to match the project-wide module cleanup Epic which standardizes native modules on PS 8.2+: - php.yml: phpstan-74 matrix now runs against 8.2.x only (PHP 7.4/8.1) - ps_versions_compliancy min bumped to 8.2.0 - remove the now-unreferenced phpstan-8.1.7.neon config Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/php.yml | 2 +- statsbestproducts.php | 2 +- tests/php/phpstan/phpstan-8.1.7.neon | 8 -------- 3 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 tests/php/phpstan/phpstan-8.1.7.neon diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 80c2c68..f1d18a1 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -36,7 +36,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - presta_version: ['8.1.7', '8.2.x'] + presta_version: ['8.2.x'] php_version: ['7.4', '8.1'] fail-fast: false env: diff --git a/statsbestproducts.php b/statsbestproducts.php index 42cb550..c8a97a1 100644 --- a/statsbestproducts.php +++ b/statsbestproducts.php @@ -111,7 +111,7 @@ public function __construct() $this->displayName = $this->trans('Best-selling products', [], 'Modules.Statsbestproducts.Admin'); $this->description = $this->trans('Enrich your stats with a small list of your best-sellers to better know your customers.', [], 'Modules.Statsbestproducts.Admin'); - $this->ps_versions_compliancy = ['min' => '1.7.6.0', 'max' => _PS_VERSION_]; + $this->ps_versions_compliancy = ['min' => '8.2.0', 'max' => _PS_VERSION_]; } public function install() diff --git a/tests/php/phpstan/phpstan-8.1.7.neon b/tests/php/phpstan/phpstan-8.1.7.neon deleted file mode 100644 index 1940ad2..0000000 --- a/tests/php/phpstan/phpstan-8.1.7.neon +++ /dev/null @@ -1,8 +0,0 @@ -includes: - - %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon - -parameters: - ignoreErrors: - - '#Property statsbestproducts::\$html is never read, only written\.#' - - '#Property ModuleGridCore::\$_direction \(string\) in isset\(\) is not nullable\.#' - - '#Offset .* does not exist on array\{avgPriceSold: string\}\.#' From b1fb9f8c2d1cf0b2b882bc953c27d24e874231ab Mon Sep 17 00:00:00 2001 From: mattgoud Date: Mon, 8 Jun 2026 18:08:13 +0200 Subject: [PATCH 5/8] Fix PHPStan errors instead of suppressing them (Epic #41648) Resolve the 3 pre-existing PHPStan errors directly and drop all ignoreErrors entries from the neon configs: - remove the unused $html property (declared, never read) - replace isset() on the non-nullable ModuleGridCore::$_direction with !empty() - declare the executeS() row shape via @var PHPDoc so the avgPriceSold/totalPriceSold array offsets are recognized Co-Authored-By: Claude Opus 4.8 (1M context) --- statsbestproducts.php | 4 ++-- tests/php/phpstan/phpstan-8.2.x.neon | 6 ------ tests/php/phpstan/phpstan-9.1.x.neon | 5 ----- tests/php/phpstan/phpstan-develop.neon | 5 ----- 4 files changed, 2 insertions(+), 18 deletions(-) diff --git a/statsbestproducts.php b/statsbestproducts.php index c8a97a1..dd33c2f 100644 --- a/statsbestproducts.php +++ b/statsbestproducts.php @@ -29,7 +29,6 @@ class statsbestproducts extends ModuleGrid { - private $html = null; private $query = null; private $columns = null; private $default_sort_column = null; @@ -177,7 +176,7 @@ public function getData() if (Validate::IsName($this->_sort)) { $this->query .= ' ORDER BY `' . bqSQL($this->_sort) . '`'; - if (isset($this->_direction) && Validate::isSortDirection($this->_direction)) { + if (!empty($this->_direction) && Validate::isSortDirection($this->_direction)) { $this->query .= ' ' . $this->_direction; } } @@ -186,6 +185,7 @@ public function getData() $this->query .= ' LIMIT ' . (int) $this->_start . ', ' . (int) $this->_limit; } + /** @var array> $values */ $values = Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->executeS($this->query); foreach ($values as &$value) { $value['avgPriceSold'] = $this->context->getCurrentLocale()->formatPrice($value['avgPriceSold'], $currency->iso_code); diff --git a/tests/php/phpstan/phpstan-8.2.x.neon b/tests/php/phpstan/phpstan-8.2.x.neon index 1940ad2..efa856c 100644 --- a/tests/php/phpstan/phpstan-8.2.x.neon +++ b/tests/php/phpstan/phpstan-8.2.x.neon @@ -1,8 +1,2 @@ includes: - %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon - -parameters: - ignoreErrors: - - '#Property statsbestproducts::\$html is never read, only written\.#' - - '#Property ModuleGridCore::\$_direction \(string\) in isset\(\) is not nullable\.#' - - '#Offset .* does not exist on array\{avgPriceSold: string\}\.#' diff --git a/tests/php/phpstan/phpstan-9.1.x.neon b/tests/php/phpstan/phpstan-9.1.x.neon index ef2df14..efa856c 100644 --- a/tests/php/phpstan/phpstan-9.1.x.neon +++ b/tests/php/phpstan/phpstan-9.1.x.neon @@ -1,7 +1,2 @@ includes: - %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon - -parameters: - ignoreErrors: - - '#Property statsbestproducts::\$html is never read, only written\.#' - - '#Property ModuleGridCore::\$_direction \(string\) in isset\(\) is not nullable\.#' diff --git a/tests/php/phpstan/phpstan-develop.neon b/tests/php/phpstan/phpstan-develop.neon index ef2df14..efa856c 100644 --- a/tests/php/phpstan/phpstan-develop.neon +++ b/tests/php/phpstan/phpstan-develop.neon @@ -1,7 +1,2 @@ includes: - %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon - -parameters: - ignoreErrors: - - '#Property statsbestproducts::\$html is never read, only written\.#' - - '#Property ModuleGridCore::\$_direction \(string\) in isset\(\) is not nullable\.#' From 259968a773c96523190cd86086656c13f84a6e41 Mon Sep 17 00:00:00 2001 From: mattgoud Date: Tue, 9 Jun 2026 16:12:47 +0200 Subject: [PATCH 6/8] CI: address review - full PHP lint matrix, PHPStan floor 7.2, add PS 9.0.3 - php-linter: add missing intermediate syntax checks (7.3, 8.1, 8.2, 8.3, 8.4) - phpstan-74: lower floor to PHP 7.2 (real minimum for PS 8.2.x) - phpstan: add PrestaShop 9.0.3 (tag, the 9.0.x branch no longer exists) + neon config Part of PrestaShop/PrestaShop#41648 Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/php.yml | 23 +++++++++++++++++++---- tests/php/phpstan/phpstan-9.0.3.neon | 2 ++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 tests/php/phpstan/phpstan-9.0.3.neon diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index f1d18a1..1c3762d 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -11,12 +11,27 @@ jobs: - name: PHP syntax checker 7.2 uses: prestashop/github-action-php-lint/7.2@master + - name: PHP syntax checker 7.3 + uses: prestashop/github-action-php-lint/7.3@master + - name: PHP syntax checker 7.4 uses: prestashop/github-action-php-lint/7.4@master - name: PHP syntax checker 8.0 uses: prestashop/github-action-php-lint/8.0@master + - name: PHP syntax checker 8.1 + uses: prestashop/github-action-php-lint/8.1@master + + - name: PHP syntax checker 8.2 + uses: prestashop/github-action-php-lint/8.2@master + + - name: PHP syntax checker 8.3 + uses: prestashop/github-action-php-lint/8.3@master + + - name: PHP syntax checker 8.4 + uses: prestashop/github-action-php-lint/8.4@master + - name: PHP syntax checker 8.5 uses: prestashop/github-action-php-lint/8.5@master @@ -30,14 +45,14 @@ jobs: with: php-version: '7.4' - # Run PHPStan against the module (PHP 7.4 – 8.1) + # Run PHPStan against the module (PHP 7.2 – 8.1) phpstan-74: - name: PHPStan (PHP 7.4 - 8.1) + name: PHPStan (PHP 7.2 - 8.1) runs-on: ubuntu-latest strategy: matrix: presta_version: ['8.2.x'] - php_version: ['7.4', '8.1'] + php_version: ['7.2', '8.1'] fail-fast: false env: PHPRC: ${{ github.workspace }}/${{ github.event.repository.name }}/.phpstan-php-ini @@ -72,7 +87,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - presta_version: ['9.1.x', 'develop'] + presta_version: ['9.0.3', '9.1.x', 'develop'] php_version: ['8.1', '8.5'] fail-fast: false env: diff --git a/tests/php/phpstan/phpstan-9.0.3.neon b/tests/php/phpstan/phpstan-9.0.3.neon new file mode 100644 index 0000000..efa856c --- /dev/null +++ b/tests/php/phpstan/phpstan-9.0.3.neon @@ -0,0 +1,2 @@ +includes: + - %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon From a4028b95d1e2237f408fcdca4a78b52caa32c706 Mon Sep 17 00:00:00 2001 From: mattgoud Date: Wed, 10 Jun 2026 15:13:44 +0200 Subject: [PATCH 7/8] CI: exclude unsupported PHP 8.5 for PrestaShop 9.0.x in PHPStan matrix PrestaShop 9.0.x supports PHP 8.1 up to 8.4 only, so the cross-product matrix was generating an invalid 9.0.3 x 8.5 combination. Switch to an explicit include list so each PrestaShop version tests its proper PHP floor and ceiling (9.0.3: 8.1/8.4, 9.1.x and develop: 8.1/8.5). Also make the "Prepare PHP env" step name reflect the actual matrix version. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/php.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 1c3762d..2b056dd 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -87,8 +87,15 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - presta_version: ['9.0.3', '9.1.x', 'develop'] - php_version: ['8.1', '8.5'] + include: + # PrestaShop 9.0.x supports PHP 8.1 up to 8.4 (8.5 is not supported) + - { presta_version: '9.0.3', php_version: '8.1' } + - { presta_version: '9.0.3', php_version: '8.4' } + # PrestaShop 9.1.x and develop support PHP 8.1 up to 8.5 + - { presta_version: '9.1.x', php_version: '8.1' } + - { presta_version: '9.1.x', php_version: '8.5' } + - { presta_version: 'develop', php_version: '8.1' } + - { presta_version: 'develop', php_version: '8.5' } fail-fast: false env: PHPRC: ${{ github.workspace }}/${{ github.event.repository.name }}/.phpstan-php-ini @@ -98,7 +105,7 @@ jobs: with: path: ${{ github.event.repository.name }} - - name: Prepare PHP env for PrestaShop 9.1.x and later (define constants before any bootstrap) + - name: Prepare PHP env for PrestaShop ${{ matrix.presta_version }} (define constants before any bootstrap) run: | mkdir -p ${{ github.event.repository.name }}/.phpstan-php-ini { From 89eac9690ecfe8d66cadc4c4bfc8a13a53bbf11e Mon Sep 17 00:00:00 2001 From: mattgoud Date: Thu, 11 Jun 2026 10:56:43 +0200 Subject: [PATCH 8/8] Bump module version to 3.0.0 Co-Authored-By: Claude Opus 4.8 (1M context) --- config.xml | 2 +- statsbestproducts.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config.xml b/config.xml index 973dbc4..a4820d0 100755 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ statsbestproducts - + diff --git a/statsbestproducts.php b/statsbestproducts.php index dd33c2f..8d528b5 100644 --- a/statsbestproducts.php +++ b/statsbestproducts.php @@ -40,7 +40,7 @@ public function __construct() { $this->name = 'statsbestproducts'; $this->tab = 'administration'; - $this->version = '2.1.0'; + $this->version = '3.0.0'; $this->author = 'PrestaShop'; $this->need_instance = 0;