From b0ff353bc3f336ce1aa35e7eb67976ee8bb7d570 Mon Sep 17 00:00:00 2001 From: Sebastian Riquelme Date: Wed, 3 Jun 2026 20:08:36 +0000 Subject: [PATCH] chore: migrate to OroCommerce 7.0 / Symfony 7 / PHP 8.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SensioFrameworkExtraBundle is gone in Symfony 7. The backend controller now uses Symfony\Bridge\Twig\Attribute\Template (matching Oro's own backend controller pattern). The frontend controller keeps $this->render() for its partial/AJAX template and #[Layout] for the full-page action, both matching Oro's frontend patterns. Routing resources must declare type:attribute (annotation loader removed in Symfony 6+). Route attributes already migrated to Symfony\Component\ Routing\Attribute\Route. Sensio ParamConverter replaced by Symfony Bridge MapEntity. Dev dependencies updated for Symfony 7 compatibility: grumphp ^1.15 requires symfony/yaml ~5.x||~6.x which conflicts with oro/platform 7.0 (symfony/yaml ~7.4); bumped to ^2.10. phpspec dropped — no specs exist and the package does not support PHP 8.5. phpstan bumped to ^2.0. phpstan 2.x is stricter with PHPDoc: @SuppressWarnings(PHPMD.*) annotations are parsed as PHPDoc and fail validation. Suppressed via identifier in phpstan.neon since these are PHPMD-only annotations. treatPhpDocTypesAsCertain set to false to silence instanceof checks against PHPDoc-typed variables. --- composer.json | 9 ++++----- ruleset/phpstan.neon | 5 +++-- .../Controller/Frontend/StockAlertController.php | 10 ++++------ .../Controller/StockAlertController.php | 4 ++-- .../StockAlertBundle/Resources/config/oro/routing.yml | 4 ++-- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index dc5afdc..b17e3f2 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,8 @@ "exclude-from-classmap": ["/Tests/"] }, "require": { - "php": "~8.3.0", - "oro/commerce": "6.0.*" + "php": "~8.5.0", + "oro/commerce": "7.0.*" }, "repositories": { "oro": { @@ -36,9 +36,8 @@ "friendsofphp/php-cs-fixer": "^3.13", "php-parallel-lint/php-parallel-lint": "^1.3", "phpmd/phpmd": "^2.13", - "phpro/grumphp": "^1.15", - "phpspec/phpspec": "^7.2", - "phpstan/phpstan": "^1.5" + "phpro/grumphp": "^2.10.0", + "phpstan/phpstan": "^2.0" }, "config": { "sort-packages": true, diff --git a/ruleset/phpstan.neon b/ruleset/phpstan.neon index 18b0548..a121e65 100644 --- a/ruleset/phpstan.neon +++ b/ruleset/phpstan.neon @@ -1,7 +1,8 @@ parameters: level: 4 reportUnmatchedIgnoredErrors: false - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false + treatPhpDocTypesAsCertain: false + ignoreErrors: + - identifier: phpDoc.parseError bootstrapFiles: - ../vendor/autoload.php \ No newline at end of file diff --git a/src/Synolia/Bundle/StockAlertBundle/Controller/Frontend/StockAlertController.php b/src/Synolia/Bundle/StockAlertBundle/Controller/Frontend/StockAlertController.php index 12d0376..8b8a72d 100644 --- a/src/Synolia/Bundle/StockAlertBundle/Controller/Frontend/StockAlertController.php +++ b/src/Synolia/Bundle/StockAlertBundle/Controller/Frontend/StockAlertController.php @@ -8,12 +8,12 @@ use Oro\Bundle\LayoutBundle\Attribute\Layout; use Oro\Bundle\ProductBundle\Entity\Product; use Oro\Bundle\SecurityBundle\Attribute\CsrfProtection; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; +use Symfony\Bridge\Doctrine\Attribute\MapEntity; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Contracts\Translation\TranslatorInterface; use Synolia\Bundle\StockAlertBundle\Entity\StockAlert; use Synolia\Bundle\StockAlertBundle\Form\Type\StockAlertType; @@ -95,8 +95,7 @@ public function indexAction(): array } #[Route(path: '/create/{id}', name: 'synolia_stock_alert_create', requirements: ['id' => '\d+']) ] - #[ParamConverter('product', class: Product::class, options: ['id' => 'id'])] - public function createAction(Product $product): JsonResponse + public function createAction(#[MapEntity(id: 'id')] Product $product): JsonResponse { try { $stockAlert = $this->handler->create($product); @@ -118,8 +117,7 @@ public function createAction(Product $product): JsonResponse #[Route(path: '/delete/{id}', name: 'synolia_stock_alert_delete', requirements: ['id' => '\d+'], methods: ['DELETE']) ] #[CsrfProtection()] - #[ParamConverter('product', class: Product::class, options: ['id' => 'id'])] - public function deleteAction(Product $product): JsonResponse + public function deleteAction(#[MapEntity(id: 'id')] Product $product): JsonResponse { try { $this->handler->deleteByProduct($product); diff --git a/src/Synolia/Bundle/StockAlertBundle/Controller/StockAlertController.php b/src/Synolia/Bundle/StockAlertBundle/Controller/StockAlertController.php index e40b4db..6c300c3 100644 --- a/src/Synolia/Bundle/StockAlertBundle/Controller/StockAlertController.php +++ b/src/Synolia/Bundle/StockAlertBundle/Controller/StockAlertController.php @@ -4,9 +4,9 @@ namespace Synolia\Bundle\StockAlertBundle\Controller; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +use Symfony\Bridge\Twig\Attribute\Template; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; use Synolia\Bundle\StockAlertBundle\Entity\StockAlert; class StockAlertController extends AbstractController diff --git a/src/Synolia/Bundle/StockAlertBundle/Resources/config/oro/routing.yml b/src/Synolia/Bundle/StockAlertBundle/Resources/config/oro/routing.yml index c3658c9..1bccfb1 100644 --- a/src/Synolia/Bundle/StockAlertBundle/Resources/config/oro/routing.yml +++ b/src/Synolia/Bundle/StockAlertBundle/Resources/config/oro/routing.yml @@ -1,11 +1,11 @@ synolia_stock_alert: resource: "@SynoliaStockAlertBundle/Controller/Frontend/StockAlertController.php" - type: annotation + type: attribute prefix: /stock-alert options: frontend: true synolia_admin_stock_alert: resource: "@SynoliaStockAlertBundle/Controller/StockAlertController.php" - type: annotation + type: attribute prefix: /stock-alert