From 528335a4385604a2bf56a168d8b289ab1ee998ab Mon Sep 17 00:00:00 2001 From: Aashan Ghimire Date: Tue, 21 Feb 2023 15:40:14 +0545 Subject: [PATCH] Support php 8.2 (#14080) * [Actions] PhpStan workflow: added PHP 8.2 * [Actions] Codeception workflow: added PHP 8.2 * Fixed phpstan issues * Updated definition of Dataobject * Fixed phpstan errors * Fixed phpstan issues * Fixed phpstan issues * Fixed phpstan issue * Updated carbon version to latest * Revert phpstan issue * Task: add changelog entry * Chore: set maximum php 8.2 * Removed unnecessary properties * Removed $renderer property, directly return string instead Set php 8.2 tests from experimental true to false and added tests for symfony 6 dev-branch and php 8.2 * Removed symfony dev branch tests for 8.1, dev branch tests with 8.2 are enough * Removed upgrade notes entry, it was already added by another pr --------- Co-authored-by: Bernhard Rusch Co-authored-by: JiaJiaJi Co-authored-by: Marco Perberschlager --- .github/workflows/codeception.yaml | 4 +++- .github/workflows/static-analysis.yaml | 4 +++- .../ClassDefinition/IndexFieldSelectionCombo.php | 1 - composer.json | 4 ++-- .../01_System_Requirements.md | 2 +- .../09_Upgrade_Notes/README.md | 1 + .../GridColumnConfig/ConfigElementInterface.php | 2 ++ .../GridColumnConfig/Operator/AbstractOperator.php | 5 +++++ .../GridColumnConfig/Operator/GeopointRenderer.php | 5 ++++- .../Operator/HotspotimageRenderer.php | 5 ++++- .../GridColumnConfig/Operator/ImageRenderer.php | 5 ++++- .../GridColumnConfig/Value/AbstractValue.php | 5 +++++ models/DataObject/ClassDefinition.php | 4 ++-- .../ClassDefinition/Data/VarExporterInterface.php | 6 ++++++ .../DataObject/ClassDefinition/Helper/VarExport.php | 12 ++++++++++++ models/DataObject/Service.php | 4 ++-- phpstan-baseline.neon | 10 +++++----- 17 files changed, 61 insertions(+), 18 deletions(-) diff --git a/.github/workflows/codeception.yaml b/.github/workflows/codeception.yaml index 502810ab16f..987e12bb5d1 100644 --- a/.github/workflows/codeception.yaml +++ b/.github/workflows/codeception.yaml @@ -40,7 +40,9 @@ jobs: strategy: matrix: include: - - { php-version: 8.1, database: "mariadb:10.6", dependencies: highest, experimental: true, storage: local, symfony: "6.3.x-dev", composer-options: "" } + - { php-version: 8.2, database: "mariadb:10.5", dependencies: highest, experimental: false, storage: local, symfony: "", composer-options: "" } + - { php-version: 8.2, database: "mariadb:10.4", dependencies: lowest, experimental: false, storage: local, symfony: "", composer-options: "" } + - { php-version: 8.2, database: "mariadb:10.6", dependencies: highest, experimental: true, storage: local, symfony: "6.3.x-dev", composer-options: "" } - { php-version: 8.1, database: "mariadb:10.7", dependencies: highest, experimental: false, storage: local, symfony: "", composer-options: "" } - { php-version: 8.1, database: "mariadb:10.3", dependencies: lowest, experimental: false, storage: local, symfony: "", composer-options: "" } - { php-version: 8.1, database: "mysql:8.0", dependencies: lowest, experimental: false, storage: local, symfony: "", composer-options: "" } diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml index 5f0a8ddfc9a..dbf4e74951d 100644 --- a/.github/workflows/static-analysis.yaml +++ b/.github/workflows/static-analysis.yaml @@ -38,9 +38,11 @@ jobs: strategy: matrix: include: + - { php-version: "8.2", dependencies: "lowest", experimental: false, symfony: "", composer-options: "" } + - { php-version: "8.2", dependencies: "highest", experimental: false, symfony: "", composer-options: "" } + - { php-version: "8.2", dependencies: "highest", experimental: true, symfony: "6.3.x-dev", composer-options: "" } - { php-version: "8.1", dependencies: "lowest", experimental: false, symfony: "", composer-options: "" } - { php-version: "8.1", dependencies: "highest", experimental: false, symfony: "", composer-options: "" } - - { php-version: "8.1", dependencies: "highest", experimental: true, symfony: "6.3.x-dev", composer-options: "" } steps: - name: "Checkout code" diff --git a/bundles/EcommerceFrameworkBundle/src/CoreExtensions/ClassDefinition/IndexFieldSelectionCombo.php b/bundles/EcommerceFrameworkBundle/src/CoreExtensions/ClassDefinition/IndexFieldSelectionCombo.php index d4b63054cc5..1e42b047fc2 100644 --- a/bundles/EcommerceFrameworkBundle/src/CoreExtensions/ClassDefinition/IndexFieldSelectionCombo.php +++ b/bundles/EcommerceFrameworkBundle/src/CoreExtensions/ClassDefinition/IndexFieldSelectionCombo.php @@ -69,7 +69,6 @@ protected function buildOptions(): array Logger::error((string) $e); } } - return $options; } diff --git a/composer.json b/composer.json index 3860ddf7825..d344eb36249 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "docs": "https://pimcore.com/docs/latest/" }, "require": { - "php": "^8.1", + "php": "~8.1.0 || ~8.2.0", "ext-SimpleXML": "*", "ext-dom": "*", "ext-exif": "*", @@ -71,7 +71,7 @@ "mpratt/embera": "^2.0.14", "myclabs/deep-copy": "^1.11", "neitanod/forceutf8": "^2.0.4", - "nesbot/carbon": "^2.27", + "nesbot/carbon": "^2.65", "pear/net_url2": "^2.2", "matomo/device-detector": "^6.0", "presta/sitemap-bundle": "^3.3", diff --git a/doc/Development_Documentation/23_Installation_and_Upgrade/01_System_Requirements.md b/doc/Development_Documentation/23_Installation_and_Upgrade/01_System_Requirements.md index 1cea52cd44d..cfa3018a28c 100644 --- a/doc/Development_Documentation/23_Installation_and_Upgrade/01_System_Requirements.md +++ b/doc/Development_Documentation/23_Installation_and_Upgrade/01_System_Requirements.md @@ -14,7 +14,7 @@ For production, we highly recommend a *nix based system. - Nginx -### PHP >= 8.1 +### PHP >=8.1 <8.3 Both **mod_php** and **FCGI (FPM)** are supported. #### Required Settings and Modules & Extensions diff --git a/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md b/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md index 5ffea23b1f6..27d119280cb 100644 --- a/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md +++ b/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md @@ -4,6 +4,7 @@ - [Logging] Removed constant `PIMCORE_PHP_ERROR_LOG` - [General] **Attention:** Added native php types for argument types, property types, return types and strict type declaration where possible. This results in **various bc breaks**. Please make sure to add the corresponding types to your implementation. +- [PHP] The minimum supported PHP version is now 8.1 and added support for 8.2 - [UrlSlug] Removed `index` column and `index` index from `object_url_slugs` table as it was not being used anywhere. - Bumped Symfony packages to "^6.2". Pimcore 11 will only support Symfony 6. - `FrontendController::renderTemplate()`: Changed the visibility to `protected`. diff --git a/lib/DataObject/GridColumnConfig/ConfigElementInterface.php b/lib/DataObject/GridColumnConfig/ConfigElementInterface.php index a9eeedf52b4..a9c128adab9 100644 --- a/lib/DataObject/GridColumnConfig/ConfigElementInterface.php +++ b/lib/DataObject/GridColumnConfig/ConfigElementInterface.php @@ -28,4 +28,6 @@ public function getLabel(): string; * @return \stdClass|ResultContainer|null */ public function getLabeledValue(array|ElementInterface $element): ResultContainer|\stdClass|null; + + public function getRenderer(): ?string; } diff --git a/lib/DataObject/GridColumnConfig/Operator/AbstractOperator.php b/lib/DataObject/GridColumnConfig/Operator/AbstractOperator.php index 7e5ba5de9a1..351c158803f 100644 --- a/lib/DataObject/GridColumnConfig/Operator/AbstractOperator.php +++ b/lib/DataObject/GridColumnConfig/Operator/AbstractOperator.php @@ -77,4 +77,9 @@ public function getValidLanguages(): array { return Tool::getValidLanguages(); } + + public function getRenderer(): ?string + { + return null; + } } diff --git a/lib/DataObject/GridColumnConfig/Operator/GeopointRenderer.php b/lib/DataObject/GridColumnConfig/Operator/GeopointRenderer.php index d337061f2e4..78f1fa4c282 100644 --- a/lib/DataObject/GridColumnConfig/Operator/GeopointRenderer.php +++ b/lib/DataObject/GridColumnConfig/Operator/GeopointRenderer.php @@ -21,5 +21,8 @@ */ final class GeopointRenderer extends AbstractRenderer { - public string $renderer = 'geopoint'; + public function getRenderer(): ?string + { + return 'geopoint'; + } } diff --git a/lib/DataObject/GridColumnConfig/Operator/HotspotimageRenderer.php b/lib/DataObject/GridColumnConfig/Operator/HotspotimageRenderer.php index 11b10fc8c4a..2a7b084cf2f 100644 --- a/lib/DataObject/GridColumnConfig/Operator/HotspotimageRenderer.php +++ b/lib/DataObject/GridColumnConfig/Operator/HotspotimageRenderer.php @@ -21,5 +21,8 @@ */ final class HotspotimageRenderer extends AbstractRenderer { - public string $renderer = 'hotspotimage'; + public function getRenderer(): ?string + { + return 'hotspotimage'; + } } diff --git a/lib/DataObject/GridColumnConfig/Operator/ImageRenderer.php b/lib/DataObject/GridColumnConfig/Operator/ImageRenderer.php index 00d936f71a2..47bb50996c3 100644 --- a/lib/DataObject/GridColumnConfig/Operator/ImageRenderer.php +++ b/lib/DataObject/GridColumnConfig/Operator/ImageRenderer.php @@ -21,5 +21,8 @@ */ final class ImageRenderer extends AbstractRenderer { - public string $renderer = 'image'; + public function getRenderer(): ?string + { + return 'image'; + } } diff --git a/lib/DataObject/GridColumnConfig/Value/AbstractValue.php b/lib/DataObject/GridColumnConfig/Value/AbstractValue.php index 3f4f32dc5a2..56c34451e3c 100644 --- a/lib/DataObject/GridColumnConfig/Value/AbstractValue.php +++ b/lib/DataObject/GridColumnConfig/Value/AbstractValue.php @@ -40,4 +40,9 @@ public function getLabel(): string { return $this->label; } + + public function getRenderer(): ?string + { + return null; + } } diff --git a/models/DataObject/ClassDefinition.php b/models/DataObject/ClassDefinition.php index 62fe3bb2f79..032029faaf0 100644 --- a/models/DataObject/ClassDefinition.php +++ b/models/DataObject/ClassDefinition.php @@ -301,8 +301,8 @@ public static function cleanupForExport(mixed &$data): void } } - if (isset($data->blockedVarsForExport)) { - unset($data->blockedVarsForExport); + if (!empty($data->getBlockedVarsForExport())) { + $data->setBlockedVarsForExport([]); } } diff --git a/models/DataObject/ClassDefinition/Data/VarExporterInterface.php b/models/DataObject/ClassDefinition/Data/VarExporterInterface.php index a6e2be7ab8c..24c32dadaae 100644 --- a/models/DataObject/ClassDefinition/Data/VarExporterInterface.php +++ b/models/DataObject/ClassDefinition/Data/VarExporterInterface.php @@ -26,4 +26,10 @@ public function getBlockedVarsForExport(): array; * @return array */ public function resolveBlockedVars(): array; + + /** + * @param array $vars + * @return $this + */ + public function setBlockedVarsForExport(array $vars): static; } diff --git a/models/DataObject/ClassDefinition/Helper/VarExport.php b/models/DataObject/ClassDefinition/Helper/VarExport.php index 891d55a9671..f259e20eb65 100644 --- a/models/DataObject/ClassDefinition/Helper/VarExport.php +++ b/models/DataObject/ClassDefinition/Helper/VarExport.php @@ -16,6 +16,8 @@ namespace Pimcore\Model\DataObject\ClassDefinition\Helper; +use Pimcore\Model\DataObject\ClassDefinition\Data\VarExporterInterface; + /** * @internal */ @@ -46,4 +48,14 @@ public static function __set_state(array $data): static return $obj; } + + /** + * @param array $vars + * @return $this + */ + public function setBlockedVarsForExport(array $vars): static + { + $this->blockedVarsForExport = $vars; + return $this; + } } diff --git a/models/DataObject/Service.php b/models/DataObject/Service.php index c393bae266d..b508d64738a 100644 --- a/models/DataObject/Service.php +++ b/models/DataObject/Service.php @@ -548,8 +548,8 @@ public static function calculateCellValue(AbstractObject $object, array $helperD if (isset($result->value)) { $result = $result->value; - if (!empty($config->renderer)) { - $classname = 'Pimcore\\Model\\DataObject\\ClassDefinition\\Data\\' . ucfirst($config->renderer); + if (!empty($config->getRenderer())) { + $classname = 'Pimcore\\Model\\DataObject\\ClassDefinition\\Data\\' . ucfirst($config->getRenderer()); /** @var Model\DataObject\ClassDefinition\Data $rendererImpl */ $rendererImpl = new $classname(); if (method_exists($rendererImpl, 'getDataForGrid')) { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 540ef95ff33..2297537291d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -5,6 +5,11 @@ parameters: count: 2 path: bundles/CoreBundle/src/DependencyInjection/PimcoreCoreExtension.php + - + message: "#^If condition is always true\\.$#" + count: 1 + path: bundles/EcommerceFrameworkBundle/src/CoreExtensions/ClassDefinition/IndexFieldSelectionCombo.php + - message: "#^If condition is always true\\.$#" count: 1 @@ -20,11 +25,6 @@ parameters: count: 1 path: bundles/EcommerceFrameworkBundle/src/Controller/VoucherController.php - - - message: "#^If condition is always true\\.$#" - count: 1 - path: bundles/EcommerceFrameworkBundle/src/CoreExtensions/ClassDefinition/IndexFieldSelectionCombo.php - - message: "#^Parameter \\#1 \\$fieldname of method Pimcore\\\\Bundle\\\\EcommerceFrameworkBundle\\\\IndexService\\\\ProductList\\\\ProductListInterface\\:\\:getGroupByValues\\(\\) expects string, Pimcore\\\\Bundle\\\\EcommerceFrameworkBundle\\\\CoreExtensions\\\\ObjectData\\\\IndexFieldSelection\\|null given\\.$#" count: 1