diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 45c9ed4..db8e3ce 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 @@ -36,7 +51,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: @@ -66,48 +81,21 @@ jobs: phpstan-version: '^0.12' composer-version: '2.2.18' - # Run PHPStan against the module (PHP 8.1 – 8.4) - phpstan-80-84: - name: PHPStan (PHP 8.1 - 8.4 ) - runs-on: ubuntu-latest - strategy: - matrix: - presta_version: ['9.0.x'] - php_version: ['8.1', '8.4'] - 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: Prepare PHP env for PrestaShop 9.0.x (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: 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 - # 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'] + 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 @@ -117,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 { diff --git a/classes/Hook/HookDisplayBeforeBodyClosingTag.php b/classes/Hook/HookDisplayBeforeBodyClosingTag.php index 33457ff..24e3a8c 100644 --- a/classes/Hook/HookDisplayBeforeBodyClosingTag.php +++ b/classes/Hook/HookDisplayBeforeBodyClosingTag.php @@ -140,7 +140,7 @@ private function renderSearch() /** * This method renders tracking code for product listings, like category pages. */ - private function renderCartpage() + private function renderCartPage() { // Check if we are on cart page if ($this->context->controller->php_self != 'cart') { diff --git a/config.xml b/config.xml index 8976d9a..cb9bf00 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ ps_googleanalytics - + diff --git a/ps_googleanalytics.php b/ps_googleanalytics.php index af89082..fa3cfee 100644 --- a/ps_googleanalytics.php +++ b/ps_googleanalytics.php @@ -47,8 +47,8 @@ public function __construct() { $this->name = 'ps_googleanalytics'; $this->tab = 'analytics_stats'; - $this->version = '5.0.3'; - $this->ps_versions_compliancy = ['min' => '8.1.0', 'max' => _PS_VERSION_]; + $this->version = '6.0.0'; + $this->ps_versions_compliancy = ['min' => '8.2.0', 'max' => _PS_VERSION_]; $this->author = 'PrestaShop'; $this->module_key = 'fd2aaefea84ac1bb512e6f1878d990b8'; $this->bootstrap = true; diff --git a/tests/php/phpstan/phpstan-1.7.7.neon b/tests/php/phpstan/phpstan-1.7.7.neon deleted file mode 100644 index caca568..0000000 --- a/tests/php/phpstan/phpstan-1.7.7.neon +++ /dev/null @@ -1,9 +0,0 @@ -includes: - - %currentWorkingDirectory%/tests/phpstan/phpstan.neon - -parameters: - ignoreErrors: - - '#PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler::uninstallModule\(\) calls parent::uninstall\(\) but PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler does not extend any class.#' - - '#Access to an undefined property Cookie\:\:\$ga_admin_order.#' - - '#Access to an undefined property Cookie\:\:\$ga_admin_refund.#' - - '#Parameter \#1 \$value of method ControllerCore::ajaxRender\(\) expects null, string given.#' diff --git a/tests/php/phpstan/phpstan-1.7.8.neon b/tests/php/phpstan/phpstan-1.7.8.neon deleted file mode 100644 index 364a960..0000000 --- a/tests/php/phpstan/phpstan-1.7.8.neon +++ /dev/null @@ -1,8 +0,0 @@ -includes: - - %currentWorkingDirectory%/tests/phpstan/phpstan.neon - -parameters: - ignoreErrors: - - '#PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler::uninstallModule\(\) calls parent::uninstall\(\) but PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler does not extend any class.#' - - '#Access to an undefined property Cookie\:\:\$ga_admin_order.#' - - '#Access to an undefined property Cookie\:\:\$ga_admin_refund.#' diff --git a/tests/php/phpstan/phpstan-8.0.neon b/tests/php/phpstan/phpstan-8.0.neon deleted file mode 100644 index 364a960..0000000 --- a/tests/php/phpstan/phpstan-8.0.neon +++ /dev/null @@ -1,8 +0,0 @@ -includes: - - %currentWorkingDirectory%/tests/phpstan/phpstan.neon - -parameters: - ignoreErrors: - - '#PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler::uninstallModule\(\) calls parent::uninstall\(\) but PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler does not extend any class.#' - - '#Access to an undefined property Cookie\:\:\$ga_admin_order.#' - - '#Access to an undefined property Cookie\:\:\$ga_admin_refund.#' diff --git a/tests/php/phpstan/phpstan-8.2.x.neon b/tests/php/phpstan/phpstan-8.2.x.neon index c02374b..914a4e6 100644 --- a/tests/php/phpstan/phpstan-8.2.x.neon +++ b/tests/php/phpstan/phpstan-8.2.x.neon @@ -3,8 +3,13 @@ includes: parameters: ignoreErrors: + # Framework / structural limitations that cannot be fixed in module code: + # - uninstallModule() calls parent::uninstall() through a closure rebound to the + # target module via Closure::bindTo(), a pattern PHPStan cannot statically resolve. + # - Cookie uses magic __get/__set, so its dynamic properties are undefined to PHPStan. + # - HookInterface mandates the constructor signature (Ps_Googleanalytics $module, Context), + # so $module must be stored even in hooks that never read it back. - '#PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler::uninstallModule\(\) calls parent::uninstall\(\) but PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler does not extend any class.#' - '#Access to an undefined property Cookie\:\:\$ga_admin_order.#' - '#Access to an undefined property Cookie\:\:\$ga_admin_refund.#' - '#Property PrestaShop\\Module\\Ps_Googleanalytics\\Hooks\\HookActionValidateOrder::\$module is never read, only written\.#' - - '#Method PrestaShop\\Module\\Ps_Googleanalytics\\Hooks\\HookDisplayBeforeBodyClosingTag::renderCartpage\(\) is unused\.#' \ No newline at end of file diff --git a/tests/php/phpstan/phpstan-8.1.7.neon b/tests/php/phpstan/phpstan-9.0.3.neon similarity index 53% rename from tests/php/phpstan/phpstan-8.1.7.neon rename to tests/php/phpstan/phpstan-9.0.3.neon index c02374b..914a4e6 100644 --- a/tests/php/phpstan/phpstan-8.1.7.neon +++ b/tests/php/phpstan/phpstan-9.0.3.neon @@ -3,8 +3,13 @@ includes: parameters: ignoreErrors: + # Framework / structural limitations that cannot be fixed in module code: + # - uninstallModule() calls parent::uninstall() through a closure rebound to the + # target module via Closure::bindTo(), a pattern PHPStan cannot statically resolve. + # - Cookie uses magic __get/__set, so its dynamic properties are undefined to PHPStan. + # - HookInterface mandates the constructor signature (Ps_Googleanalytics $module, Context), + # so $module must be stored even in hooks that never read it back. - '#PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler::uninstallModule\(\) calls parent::uninstall\(\) but PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler does not extend any class.#' - '#Access to an undefined property Cookie\:\:\$ga_admin_order.#' - '#Access to an undefined property Cookie\:\:\$ga_admin_refund.#' - '#Property PrestaShop\\Module\\Ps_Googleanalytics\\Hooks\\HookActionValidateOrder::\$module is never read, only written\.#' - - '#Method PrestaShop\\Module\\Ps_Googleanalytics\\Hooks\\HookDisplayBeforeBodyClosingTag::renderCartpage\(\) is unused\.#' \ No newline at end of file diff --git a/tests/php/phpstan/phpstan-9.0.x.neon b/tests/php/phpstan/phpstan-9.0.x.neon deleted file mode 100644 index 00dcfae..0000000 --- a/tests/php/phpstan/phpstan-9.0.x.neon +++ /dev/null @@ -1,9 +0,0 @@ -includes: - - %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon - -parameters: - ignoreErrors: - - '#PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler::uninstallModule\(\) calls parent::uninstall\(\) but PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler does not extend any class.#' - - '#Access to an undefined property Cookie\:\:\$ga_admin_order.#' - - '#Access to an undefined property Cookie\:\:\$ga_admin_refund.#' - - '#Property PrestaShop\\Module\\Ps_Googleanalytics\\Hooks\\HookActionValidateOrder::\$module is never read, only written\.#' \ No newline at end of file diff --git a/tests/php/phpstan/phpstan-9.1.x.neon b/tests/php/phpstan/phpstan-9.1.x.neon index 00dcfae..914a4e6 100644 --- a/tests/php/phpstan/phpstan-9.1.x.neon +++ b/tests/php/phpstan/phpstan-9.1.x.neon @@ -3,7 +3,13 @@ includes: parameters: ignoreErrors: + # Framework / structural limitations that cannot be fixed in module code: + # - uninstallModule() calls parent::uninstall() through a closure rebound to the + # target module via Closure::bindTo(), a pattern PHPStan cannot statically resolve. + # - Cookie uses magic __get/__set, so its dynamic properties are undefined to PHPStan. + # - HookInterface mandates the constructor signature (Ps_Googleanalytics $module, Context), + # so $module must be stored even in hooks that never read it back. - '#PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler::uninstallModule\(\) calls parent::uninstall\(\) but PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler does not extend any class.#' - '#Access to an undefined property Cookie\:\:\$ga_admin_order.#' - '#Access to an undefined property Cookie\:\:\$ga_admin_refund.#' - - '#Property PrestaShop\\Module\\Ps_Googleanalytics\\Hooks\\HookActionValidateOrder::\$module is never read, only written\.#' \ No newline at end of file + - '#Property PrestaShop\\Module\\Ps_Googleanalytics\\Hooks\\HookActionValidateOrder::\$module is never read, only written\.#' diff --git a/tests/php/phpstan/phpstan-develop.neon b/tests/php/phpstan/phpstan-develop.neon index 00dcfae..914a4e6 100644 --- a/tests/php/phpstan/phpstan-develop.neon +++ b/tests/php/phpstan/phpstan-develop.neon @@ -3,7 +3,13 @@ includes: parameters: ignoreErrors: + # Framework / structural limitations that cannot be fixed in module code: + # - uninstallModule() calls parent::uninstall() through a closure rebound to the + # target module via Closure::bindTo(), a pattern PHPStan cannot statically resolve. + # - Cookie uses magic __get/__set, so its dynamic properties are undefined to PHPStan. + # - HookInterface mandates the constructor signature (Ps_Googleanalytics $module, Context), + # so $module must be stored even in hooks that never read it back. - '#PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler::uninstallModule\(\) calls parent::uninstall\(\) but PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler does not extend any class.#' - '#Access to an undefined property Cookie\:\:\$ga_admin_order.#' - '#Access to an undefined property Cookie\:\:\$ga_admin_refund.#' - - '#Property PrestaShop\\Module\\Ps_Googleanalytics\\Hooks\\HookActionValidateOrder::\$module is never read, only written\.#' \ No newline at end of file + - '#Property PrestaShop\\Module\\Ps_Googleanalytics\\Hooks\\HookActionValidateOrder::\$module is never read, only written\.#' diff --git a/tests/php/phpstan/phpstan-latest.neon b/tests/php/phpstan/phpstan-latest.neon deleted file mode 100644 index 364a960..0000000 --- a/tests/php/phpstan/phpstan-latest.neon +++ /dev/null @@ -1,8 +0,0 @@ -includes: - - %currentWorkingDirectory%/tests/phpstan/phpstan.neon - -parameters: - ignoreErrors: - - '#PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler::uninstallModule\(\) calls parent::uninstall\(\) but PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler does not extend any class.#' - - '#Access to an undefined property Cookie\:\:\$ga_admin_order.#' - - '#Access to an undefined property Cookie\:\:\$ga_admin_refund.#'