Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 95 additions & 27 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,38 +56,106 @@ jobs:
- name: Run PHP-CS-Fixer
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no --diff-format udiff

# Run PHPStan against the module and a PrestaShop release
phpstan:
name: PHPStan
# Run PHPStan against the module (PHP 7.4 – PS 8.2)
phpstan-74-81:
name: PHPStan (PHP 7.4 - 8.1)
runs-on: ubuntu-latest
strategy:
matrix:
presta-versions: ['1.7.6', '1.7.7', '1.7.8', '8.0', 'latest']
presta_version: ['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: Setup PHP
uses: shivammathur/setup-php@v2
- name: Checkout repository
uses: actions/checkout@v6
with:
php-version: '7.4'

- name: Checkout
uses: actions/checkout@v2.0.0

# Add vendor folder in cache to make next builds faster
- name: Cache vendor folder
uses: actions/cache@v4
path: ${{ github.event.repository.name }}

- 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: Run PHPStan
uses: PrestaShop/.github/.github/actions/php-ci/phpstan@master
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}

# Add composer local folder in cache to make next builds faster
- name: Cache composer folder
uses: actions/cache@v4
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'

# Run PHPStan against the module (PHP 8.1 – 8.4)
phpstan-81-84:
name: PHPStan (PHP 8.1 - 8.4)
runs-on: ubuntu-latest
strategy:
matrix:
presta_version: ['9.0.3']
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: ~/.composer/cache
key: php-composer-cache

- run: composer install
path: ${{ github.event.repository.name }}

- 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

- 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

# 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 }}
# 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: 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

- 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
5 changes: 3 additions & 2 deletions dashproducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ public function getTableBestSellers($date_from, $date_to)
}

$productCategoryId = $product_obj->getDefaultCategory();
// @phpstan-ignore-next-line (Need for 8.2.x)
if (is_array($productCategoryId) && isset($productCategoryId['id_category_default'])) {
$productCategoryId = $productCategoryId['id_category_default'];
}
Expand All @@ -231,7 +232,7 @@ public function getTableBestSellers($date_from, $date_to)
$img = '';
if (($row_image = Product::getCover($product_obj->id)) && $row_image['id_image']) {
$image = new Image((int) $row_image['id_image']);
$path_to_image = (defined('_PS_PRODUCT_IMG_DIR_') ? _PS_PRODUCT_IMG_DIR_ : _PS_PROD_IMG_DIR_) . $image->getExistingImgPath() . '.' . $this->context->controller->imageType;
$path_to_image = _PS_PRODUCT_IMG_DIR_ . $image->getExistingImgPath() . '.' . $this->context->controller->imageType;
$img = ImageManager::thumbnail($path_to_image, 'product_mini_' . $row_image['id_image'] . '.' . $this->context->controller->imageType, 45, $this->context->controller->imageType);
}

Expand Down Expand Up @@ -326,7 +327,7 @@ public function getTableMostViewed($date_from, $date_to)
$img = '';
if (($row_image = Product::getCover($product_obj->id)) && $row_image['id_image']) {
$image = new Image((int) $row_image['id_image']);
$path_to_image = (defined('_PS_PRODUCT_IMG_DIR_') ? _PS_PRODUCT_IMG_DIR_ : _PS_PROD_IMG_DIR_) . $image->getExistingImgPath() . '.' . $this->context->controller->imageType;
$path_to_image = _PS_PRODUCT_IMG_DIR_ . $image->getExistingImgPath() . '.' . $this->context->controller->imageType;
$img = ImageManager::thumbnail(
$path_to_image,
'product_mini_' . $product_obj->id . '.' . $this->context->controller->imageType,
Expand Down
34 changes: 34 additions & 0 deletions tests/php/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* 2007-2020 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
File renamed without changes.
2 changes: 2 additions & 0 deletions tests/php/phpstan/phpstan-8.2.x.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
includes:
- %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon
2 changes: 2 additions & 0 deletions tests/php/phpstan/phpstan-9.0.3.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
includes:
- %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon
2 changes: 2 additions & 0 deletions tests/php/phpstan/phpstan-9.1.x.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
includes:
- %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon
2 changes: 2 additions & 0 deletions tests/php/phpstan/phpstan-develop.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
includes:
- %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon
2 changes: 2 additions & 0 deletions tests/php/phpstan/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Base PHPStan configuration for the module
# This file is included by version-specific configs
11 changes: 11 additions & 0 deletions tests/php/phpstan/prepend-constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
/**
* Defines constants required by PrestaShop config (e.g. defines_uri.inc.php) when running
* PHPStan outside a full request. Loaded via auto_prepend_file in CI for 9.x jobs.
*/
if (!defined('_THEME_NAME_')) {
define('_THEME_NAME_', 'classic');
}
if (!defined('__PS_BASE_URI__')) {
define('__PS_BASE_URI__', '/');
}
28 changes: 0 additions & 28 deletions tests/phpstan.sh

This file was deleted.

9 changes: 0 additions & 9 deletions tests/phpstan/phpstan-1.7.6.neon

This file was deleted.

9 changes: 0 additions & 9 deletions tests/phpstan/phpstan-1.7.7.neon

This file was deleted.

9 changes: 0 additions & 9 deletions tests/phpstan/phpstan-1.7.8.neon

This file was deleted.

3 changes: 0 additions & 3 deletions tests/phpstan/phpstan-8.0.neon

This file was deleted.

2 changes: 0 additions & 2 deletions tests/phpstan/phpstan-latest.neon

This file was deleted.

8 changes: 0 additions & 8 deletions tests/phpstan/phpstan.neon

This file was deleted.

Loading