Skip to content

Commit

Permalink
update php and pimcore, fix deprecations (#448)
Browse files Browse the repository at this point in the history
* update php and pimcore, fix deprecations

* update php and pimcore, fix deprecations
  • Loading branch information
alexz707 authored Jan 20, 2025
1 parent 336d65f commit 25bb317
Show file tree
Hide file tree
Showing 37 changed files with 189 additions and 133 deletions.
133 changes: 73 additions & 60 deletions .github/workflows/codeception.yml
Original file line number Diff line number Diff line change
@@ -1,81 +1,94 @@

name: "Codeception Tests"
name: "Codeception Tests centralised"

on:
schedule:
- cron: '0 3 * * 1,3,5'
pull_request:
branches:
- "[0-9]+.[0-9]+"
- "[0-9]+.x"
workflow_dispatch:
push:
branches:
- "[0-9]+.[0-9]+"
- "[0-9]+.x"
- "feature-*"
pull_request:
types: [opened, synchronize, reopened]

env:
PIMCORE_PROJECT_ROOT: ${{ github.workspace }}
APP_ENV: test
PIMCORE_TEST: 1
PIMCORE_TEST_DB_DSN: "mysql://[email protected]:33006/pimcore_test"
PIMCORE_ELASTIC_SEARCH_HOST: 'localhost:39200'
PRIVATE_REPO: ${{ github.event.repository.private }}

jobs:
codeception-tests:
name: "Codeception tests"
runs-on: "ubuntu-20.04"
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
include:
- { php-version: 8.1, database: "mariadb:10.11", pimcore_version: "", dependencies: lowest, experimental: false }
- { php-version: 8.3, database: "mariadb:10.11", pimcore_version: "", dependencies: highest, experimental: false }
- { php-version: 8.3, database: "mariadb:10.11", pimcore_version: "11.x-dev", dependencies: highest, experimental: true }
services:
mariadb:
image: "${{ matrix.database }}"
ports:
- 33006:3306
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes

setup-matrix:
runs-on: ubuntu-latest
outputs:
php_versions: ${{ steps.parse-php-versions.outputs.php_versions }}
matrix: ${{ steps.set-matrix.outputs.matrix }}
private_repo: ${{ env.PRIVATE_REPO }}
steps:
- name: "Checkout code"
uses: "actions/checkout@v2"
- name: Checkout code
uses: actions/checkout@v4

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
- name: Checkout reusable workflow repo
uses: actions/checkout@v4
with:
coverage: "none"
extensions: imagick
ini-values: display_errors=On, display_startup_errors=On, error_reporting=32767
php-version: "${{ matrix.php-version }}"

- name: Verify MariaDB connection
run: |
cp .github/ci/files/.my.cnf ~/.my.cnf
while ! mysqladmin ping --silent; do
sleep 1
done
repository: pimcore/workflows-collection-public
ref: main
path: reusable-workflows

- name: "Setup Pimcore environment"
- name: Parse PHP versions from composer.json
id: parse-php-versions
run: |
mysql -e "CREATE DATABASE pimcore_test CHARSET=utf8mb4;"
chmod 755 .github/ci/scripts/setup-pimcore-environment.sh
.github/ci/scripts/setup-pimcore-environment.sh
if [ -f composer.json ]; then
php_versions=$(jq -r '.require.php' composer.json | grep -oP '\d+\.\d+' | tr '\n' ',' | sed 's/,$//')
if [ -z "$php_versions" ]; then
echo "No PHP versions found in composer.json"
echo "Setting default PHP value"
echo "php_versions=default" >> $GITHUB_OUTPUT
else
echo "php_versions=$php_versions" >> $GITHUB_OUTPUT
echo "#### php versions #### : $php_versions"
fi
else
echo "composer.json not found"
exit 1
fi
- name: "Update Pimcore version"
env:
PIMCORE_VERSION: "${{ matrix.pimcore_version }}"
- name: Set up matrix
id: set-matrix
run: |
if [ ! -z "$PIMCORE_VERSION" ]; then
composer require --no-update pimcore/pimcore:"${PIMCORE_VERSION}"
fi
php_versions="${{ steps.parse-php-versions.outputs.php_versions }}"
MATRIX_JSON=$(cat reusable-workflows/codeception-tests-configuration/matrix-config.json)
IFS=',' read -ra VERSIONS_ARRAY <<< "$php_versions"
FILTERED_MATRIX_JSON=$(echo $MATRIX_JSON | jq --arg php_versions "$php_versions" '
{
matrix: [
.configs[] |
select(.php_version == $php_versions) |
.matrix[]
]
}')
ENCODED_MATRIX_JSON=$(echo $FILTERED_MATRIX_JSON | jq -c .)
echo "matrix=${ENCODED_MATRIX_JSON}" >> $GITHUB_OUTPUT
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: "Run Codeception"
run: "vendor/bin/codecept run -c . -vvv --xml"
codeception-tests:
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
uses: pimcore/workflows-collection-public/.github/workflows/reusable-codeception-tests-centralized.yaml@main
with:
APP_ENV: test
PIMCORE_TEST: 1
PRIVATE_REPO: ${{ needs.setup-matrix.outputs.private_repo}}
PHP_VERSION: ${{ matrix.matrix.php-version }}
DATABASE: ${{ matrix.matrix.database }}
SERVER_VERSION: ${{ matrix.matrix.server_version }}
DEPENDENCIES: ${{ matrix.matrix.dependencies }}
EXPERIMENTAL: ${{ matrix.matrix.experimental }}
PIMCORE_VERSION: ${{ matrix.matrix.pimcore_version }}
secrets:
SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN: ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
114 changes: 78 additions & 36 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,95 @@
name: "Static Analysis"
name: "Static analysis centralised"

on:
schedule:
- cron: '0 3 * * 1,3,5'
pull_request:
branches:
- "[0-9]+.[0-9]+"
- "[0-9]+.x"
- cron: '0 3 * * 1,3,5'
workflow_dispatch:
push:
branches:
- "[0-9]+.[0-9]+"
- "[0-9]+.x"
- "feature-*"
pull_request:
types: [ opened, synchronize, reopened ]


env:
PIMCORE_PROJECT_ROOT: ${{ github.workspace }}
PRIVATE_REPO: ${{ github.event.repository.private }}

jobs:
static-analysis-phpstan:
name: "Static Analysis with PHPStan"
runs-on: "ubuntu-20.04"
strategy:
matrix:
include:
- { php-version: "8.1", dependencies: "lowest" }
- { php-version: "8.3", dependencies: "highest" }
- { php-version: "8.3", dependencies: "highest", pimcore_version: "11.x-dev", experimental: true }
setup-matrix:
runs-on: ubuntu-latest
outputs:
php_versions: ${{ steps.parse-php-versions.outputs.php_versions }}
matrix: ${{ steps.set-matrix.outputs.matrix }}
private_repo: ${{ env.PRIVATE_REPO }}
steps:
- name: "Checkout code"
uses: "actions/checkout@v2"
- name: Checkout code
uses: actions/checkout@v4

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
- name: Checkout reusable workflow repo
uses: actions/checkout@v4
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
repository: pimcore/workflows-collection-public
ref: main
path: reusable-workflows

- name: "Setup Pimcore environment"
- name: Parse PHP versions from composer.json
id: parse-php-versions
run: |
.github/ci/scripts/setup-pimcore-environment.sh
if [ -f composer.json ]; then
php_versions=$(jq -r '.require.php' composer.json | grep -oP '\d+\.\d+' | tr '\n' ',' | sed 's/,$//')
if [ -z "$php_versions" ]; then
echo "No PHP versions found in composer.json"
echo "Setting default PHP value"
echo "php_versions=default" >> $GITHUB_OUTPUT
else
echo "php_versions=$php_versions" >> $GITHUB_OUTPUT
echo "#### php versions #### : $php_versions"
fi
else
echo "composer.json not found"
exit 1
fi
- name: "Update Pimcore version"
env:
PIMCORE_VERSION: "${{ matrix.pimcore_version }}"
- name: Set up matrix
id: set-matrix
run: |
if [ ! -z "$PIMCORE_VERSION" ]; then
composer require --no-update pimcore/pimcore:"${PIMCORE_VERSION}"
fi
php_versions="${{ steps.parse-php-versions.outputs.php_versions }}"
MATRIX_JSON=$(cat reusable-workflows/phpstan-configuration/matrix-config.json)
IFS=',' read -ra VERSIONS_ARRAY <<< "$php_versions"
FILTERED_MATRIX_JSON=$(echo $MATRIX_JSON | jq --arg php_versions "$php_versions" '
{
matrix: [
.configs[] |
select(.php_version == $php_versions) |
.matrix[]
]
}')
ENCODED_MATRIX_JSON=$(echo $FILTERED_MATRIX_JSON | jq -c .)
echo "matrix=${ENCODED_MATRIX_JSON}" >> $GITHUB_OUTPUT
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan analyse --memory-limit=-1"
static-analysis:
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
uses: pimcore/workflows-collection-public/.github/workflows/reusable-static-analysis-centralized.yaml@main
with:
APP_ENV: test
PIMCORE_TEST: 1
PRIVATE_REPO: ${{ needs.setup-matrix.outputs.private_repo}}
PHP_VERSION: ${{ matrix.matrix.php-version }}
SYMFONY: ${{ matrix.matrix.symfony }}
DEPENDENCIES: ${{ matrix.matrix.dependencies }}
EXPERIMENTAL: ${{ matrix.matrix.experimental }}
PIMCORE_VERSION: ${{ matrix.matrix.pimcore_version }}
COMPOSER_OPTIONS: ${{ matrix.matrix.composer_options }}
secrets:
SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN: ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
"ext-fileinfo": "*",
"ext-json": "*",
"doctrine/dbal": "^2.12 || ^3.8",
"dragonmantank/cron-expression": "^3.1",
"league/flysystem-sftp-v3": "^3.0",
"nesbot/carbon": "^2.72",
"phpoffice/phpspreadsheet": "^2.2 || ^3.3",
"pimcore/admin-ui-classic-bundle": "^1.0",
"pimcore/admin-ui-classic-bundle": "^1.0 || 2.x-dev",
"pimcore/data-hub": "^1.6",
"pimcore/pimcore": "^11.2",
"pimcore/pimcore": "^11.2 || 12.x-dev",
"symfony/mime": "^5.2 || ^6.2",
"webmozarts/console-parallelization": "^1.2.0 || ^2.0.0"
},
Expand All @@ -33,6 +33,7 @@
"codeception/module-symfony": "^1.6.0 || ^3.1.0",
"codeception/phpunit-wrapper": "^9",
"phpstan/phpstan": "1.12.5",
"phpstan/phpstan-symfony": "^1.3.5",
"phpunit/phpunit": "^9.3"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion src/DataSource/Interpreter/DeltaChecker/DeltaChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(Connection $connection)
*
* @throws Exception
*/
protected function createTableIfNotExisting(\Closure $callable = null)
protected function createTableIfNotExisting(?\Closure $callable = null)
{
$this->db->executeQuery(sprintf('CREATE TABLE IF NOT EXISTS %s (
configName varchar(80) NOT NULL,
Expand Down
2 changes: 1 addition & 1 deletion src/DataSource/Interpreter/InterpreterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(array $interpreterBluePrints)
*
* @throws InvalidConfigurationException
*/
public function loadInterpreter(string $configName, array $interpreterConfiguration, array $processingConfiguration, Resolver $resolver = null)
public function loadInterpreter(string $configName, array $interpreterConfiguration, array $processingConfiguration, ?Resolver $resolver = null)
{
if (empty($interpreterConfiguration['type']) || !array_key_exists($interpreterConfiguration['type'], $this->interpreterBluePrints)) {
throw new InvalidConfigurationException('Unknown loader type `' . ($interpreterConfiguration['type'] ?? '') . '`');
Expand Down
2 changes: 1 addition & 1 deletion src/Mapping/Operator/Factory/AsArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function process($inputData, bool $dryRun = false)
*
* @return string
*/
public function evaluateReturnType(string $inputType, int $index = null): string
public function evaluateReturnType(string $inputType, ?int $index = null): string
{
return TransformationDataTypeService::DEFAULT_ARRAY;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mapping/Operator/Factory/AsColor.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function generateResultPreview($inputData)
*
* @return string
*/
public function evaluateReturnType(string $inputType, int $index = null): string
public function evaluateReturnType(string $inputType, ?int $index = null): string
{
return TransformationDataTypeService::RGBA_COLOR;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mapping/Operator/Factory/AsCountries.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function process(mixed $inputData, bool $dryRun = false): mixed
*
* @throws InvalidConfigurationException
*/
public function evaluateReturnType(string $inputType, int $index = null): string
public function evaluateReturnType(string $inputType, ?int $index = null): string
{
if ($inputType != TransformationDataTypeService::DEFAULT_ARRAY) {
throw new InvalidConfigurationException(sprintf("Unsupported input type '%s' for as countries operator at transformation position %s", $inputType, $index));
Expand Down
2 changes: 1 addition & 1 deletion src/Mapping/Operator/Factory/AsGeobounds.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function generateResultPreview($inputData)
*
* @throws InvalidConfigurationException
*/
public function evaluateReturnType(string $inputType, int $index = null): string
public function evaluateReturnType(string $inputType, ?int $index = null): string
{
if ($inputType !== TransformationDataTypeService::DEFAULT_ARRAY) {
throw new InvalidConfigurationException(sprintf("Unsupported input type '%s' for geoBounds operator at transformation position %s", $inputType, $index));
Expand Down
2 changes: 1 addition & 1 deletion src/Mapping/Operator/Factory/AsGeopoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function generateResultPreview($inputData)
*
* @throws InvalidConfigurationException
*/
public function evaluateReturnType(string $inputType, int $index = null): string
public function evaluateReturnType(string $inputType, ?int $index = null): string
{
if ($inputType !== TransformationDataTypeService::DEFAULT_ARRAY) {
throw new InvalidConfigurationException(sprintf("Unsupported input type '%s' for geoPoint operator at transformation position %s", $inputType, $index));
Expand Down
2 changes: 1 addition & 1 deletion src/Mapping/Operator/Factory/AsGeopolygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AsGeopolygon extends GeopolyAbstractOperator
*
* @throws InvalidConfigurationException
*/
public function evaluateReturnType(string $inputType, int $index = null): string
public function evaluateReturnType(string $inputType, ?int $index = null): string
{
if ($inputType !== TransformationDataTypeService::DEFAULT_ARRAY) {
throw new InvalidConfigurationException(sprintf("Unsupported input type '%s' for geoPolygon operator at transformation position %s", $inputType, $index));
Expand Down
2 changes: 1 addition & 1 deletion src/Mapping/Operator/Factory/AsGeopolyline.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AsGeopolyline extends GeopolyAbstractOperator
*
* @throws InvalidConfigurationException
*/
public function evaluateReturnType(string $inputType, int $index = null): string
public function evaluateReturnType(string $inputType, ?int $index = null): string
{
if ($inputType !== TransformationDataTypeService::DEFAULT_ARRAY) {
throw new InvalidConfigurationException(sprintf("Unsupported input type '%s' for geoPolyline operator at transformation position %s", $inputType, $index));
Expand Down
Loading

0 comments on commit 25bb317

Please sign in to comment.