Skip to content

[Behat] Update elements config from xml to php#18860

Merged
TheMilek merged 1 commit intoSylius:2.3from
NoResponseMate:behat/update-services-definition-to-php-elements
Feb 23, 2026
Merged

[Behat] Update elements config from xml to php#18860
TheMilek merged 1 commit intoSylius:2.3from
NoResponseMate:behat/update-services-definition-to-php-elements

Conversation

@NoResponseMate
Copy link
Copy Markdown
Contributor

@NoResponseMate NoResponseMate commented Feb 20, 2026

Q A
Branch? 2.3
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Related tickets partially #18822
License MIT

Summary by CodeRabbit

  • Chores
    • Migrated Behat service configuration from XML to PHP.
    • Added new PHP-based registrations for admin, product, product-attribute, shop and common Behat UI elements.
    • Removed legacy XML service definitions for those Behat elements to finalize the migration.

@NoResponseMate NoResponseMate requested review from a team as code owners February 20, 2026 16:31
@NoResponseMate NoResponseMate added Behat Issues and PRs aimed at improving Behat usage. Maintenance CI configurations, READMEs, releases, etc. labels Feb 20, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 20, 2026

📝 Walkthrough

Walkthrough

This PR migrates Sylius Behat element service registrations from XML to PHP: it removes XML service files and adds equivalent PHP DI configuration files, and updates the main services loader to import PHP element configs instead of XML.

Changes

Cohort / File(s) Summary
Service loader configuration
src/Sylius/Behat/Resources/config/services.php
Changed import pattern to load services/elements/**/*.php instead of services/elements/**/*.xml.
Admin elements
src/Sylius/Behat/Resources/config/services/elements/admin.php, src/Sylius/Behat/Resources/config/services/elements/admin.xml
Removed XML and added PHP file re-registering admin Behat element services (CRUD forms, filters, channel/admin elements, promotions, tax, currency, locales, customer/group forms, etc.).
Admin — product forms
src/Sylius/Behat/Resources/config/services/elements/admin/product.php, .../admin/product.xml
Replaced XML with PHP definitions for seven admin product form element services; injects AutocompleteHelperInterface where applicable.
Admin — product attribute
src/Sylius/Behat/Resources/config/services/elements/admin/product_attribute.php, .../admin/product_attribute.xml
Replaced product_attribute XML with PHP registering form and filter element services (with AutocompleteHelper injection for form).
Common elements
src/Sylius/Behat/Resources/config/services/elements/common.php, .../common.xml
Replaced abstract base sylius.behat.element plus browser and save element services from XML with PHP DI equivalents.
Product (show/index) elements
src/Sylius/Behat/Resources/config/services/elements/product.php, .../product.xml
Migrated product show/index element registrations (associations, attributes, details, media, pricing, shipping, taxonomy, options, variants, vertical menu, lowest price info) from XML to PHP.
Shop elements
src/Sylius/Behat/Resources/config/services/elements/shop.php, .../shop.xml
Replaced shop element XML with PHP bindings (account register, menu, cart widget, checkout subtotal) and interface-to-implementation bindings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • GSadee

Poem

"🐰 I hopped from tags to tidy code today,
XML fell off as I bounded away,
PHP files now line the service trail,
Elements wake up and wag their tail,
Configs snug as carrots — hip hooray! 🥕"

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[Behat] Update elements config from xml to php' clearly and concisely summarizes the primary change: migrating Behat service configuration files from XML to PHP format.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 20, 2026

❌ Preview Environment deleted from Bunnyshell

Available commands:

  • 🚀 /bns:deploy to redeploy the environment

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (6)
src/Sylius/Behat/Resources/config/services/elements/shop.php (1)

14-21: use imports are not sorted alphabetically.

MenuElement (line 15) should come after all CartWidget* and CheckoutSubtotal* imports. As per coding guidelines: "Sort PHP use imports alphabetically."

♻️ Proposed fix
 use Sylius\Behat\Element\Shop\Account\RegisterElement;
-use Sylius\Behat\Element\Shop\MenuElement;
 use Sylius\Behat\Element\Shop\CartWidgetElementInterface;
 use Sylius\Behat\Element\Shop\CartWidgetElement;
 use Sylius\Behat\Element\Shop\CheckoutSubtotalElementInterface;
 use Sylius\Behat\Element\Shop\CheckoutSubtotalElement;
+use Sylius\Behat\Element\Shop\MenuElement;
 use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
 use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Resources/config/services/elements/shop.php` around lines 14
- 21, The use imports are not alphabetically ordered: move MenuElement so
imports follow alphabetical order relative to CartWidgetElementInterface,
CartWidgetElement, CheckoutSubtotalElementInterface, CheckoutSubtotalElement;
update the import block (affecting symbols MenuElement,
CartWidgetElementInterface, CartWidgetElement, CheckoutSubtotalElementInterface,
CheckoutSubtotalElement) so all use statements are sorted alphabetically to
comply with the project's coding guidelines.
src/Sylius/Behat/Resources/config/services/elements/admin/product_attribute.php (1)

14-18: use imports are not sorted alphabetically.

FilterElement (line 16) should precede FormElement (line 14) (Filter < Form), and AutocompleteHelperInterface (from Sylius\Behat\Service\) should follow both Element\ imports.

As per coding guidelines: "Sort PHP use imports alphabetically."

♻️ Proposed fix
-use Sylius\Behat\Element\Admin\ProductAttribute\FormElement;
-use Sylius\Behat\Service\Helper\AutocompleteHelperInterface;
-use Sylius\Behat\Element\Admin\ProductAttribute\FilterElement;
+use Sylius\Behat\Element\Admin\ProductAttribute\FilterElement;
+use Sylius\Behat\Element\Admin\ProductAttribute\FormElement;
+use Sylius\Behat\Service\Helper\AutocompleteHelperInterface;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/Sylius/Behat/Resources/config/services/elements/admin/product_attribute.php`
around lines 14 - 18, The use-imports in this file are not alphabetized; reorder
the imports so they are sorted alphabetically by full import string: place
Sylius\Behat\Element\Admin\ProductAttribute\FilterElement before
Sylius\Behat\Element\Admin\ProductAttribute\FormElement, and ensure
Sylius\Behat\Service\Helper\AutocompleteHelperInterface comes after the two
Element imports; keep the Symfony imports
(Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator
and the service function) in their proper alphabetical positions as well so all
use statements are fully sorted.
src/Sylius/Behat/Resources/config/services/elements/admin/product.php (1)

14-23: use imports are not sorted alphabetically.

Sylius\Behat\Element\Admin\Product\* (lines 16–21) should precede Sylius\Behat\Element\Admin\ProductAssociationType\FormElement (line 14), and Sylius\Behat\Service\Helper\AutocompleteHelperInterface (line 15, a Service\ namespace) should follow all Element\ imports.

As per coding guidelines: "Sort PHP use imports alphabetically."

♻️ Proposed fix
-use Sylius\Behat\Element\Admin\ProductAssociationType\FormElement;
-use Sylius\Behat\Service\Helper\AutocompleteHelperInterface;
-use Sylius\Behat\Element\Admin\Product\AssociationsFormElement;
-use Sylius\Behat\Element\Admin\Product\AttributesFormElement;
-use Sylius\Behat\Element\Admin\Product\ChannelPricingsFormElement;
-use Sylius\Behat\Element\Admin\Product\MediaFormElement;
-use Sylius\Behat\Element\Admin\Product\TaxonomyFormElement;
-use Sylius\Behat\Element\Admin\Product\TranslationsFormElement;
+use Sylius\Behat\Element\Admin\Product\AssociationsFormElement;
+use Sylius\Behat\Element\Admin\Product\AttributesFormElement;
+use Sylius\Behat\Element\Admin\Product\ChannelPricingsFormElement;
+use Sylius\Behat\Element\Admin\Product\MediaFormElement;
+use Sylius\Behat\Element\Admin\Product\TaxonomyFormElement;
+use Sylius\Behat\Element\Admin\Product\TranslationsFormElement;
+use Sylius\Behat\Element\Admin\ProductAssociationType\FormElement;
+use Sylius\Behat\Service\Helper\AutocompleteHelperInterface;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Resources/config/services/elements/admin/product.php` around
lines 14 - 23, Reorder the PHP use statements so they are alphabetically sorted:
move all Sylius\Behat\Element\Admin\Product\* imports (AssociationsFormElement,
AttributesFormElement, ChannelPricingsFormElement, MediaFormElement,
TaxonomyFormElement, TranslationsFormElement) before
Sylius\Behat\Element\Admin\ProductAssociationType\FormElement and place
Sylius\Behat\Service\Helper\AutocompleteHelperInterface after the Element
imports; ensure
Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator
and the service() import remain in correct alphabetical order relative to the
others so the entire block is alphabetized.
src/Sylius/Behat/Resources/config/services/elements/product.php (1)

14-27: use imports are not sorted alphabetically.

Within the ShowPage namespace, TranslationsElement (T) appears before PricingElement (P), OptionsElement (O) appears after ShippingElement/TaxonomyElement, and the LowestPrice* imports should be grouped between DetailsElement and MediaElement. VerticalMenuElement (from IndexPage, which sorts before ShowPage) should also precede the ShowPage imports.

As per coding guidelines: "Sort PHP use imports alphabetically."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Resources/config/services/elements/product.php` around lines
14 - 27, The use imports are out-of-order; reorder them alphabetically and group
related namespaces: place VerticalMenuElement (IndexPage) before the ShowPage
imports, then within ShowPage sort alphabetically so DetailsElement is followed
by LowestPriceInformationElementInterface and LowestPriceInformationElement,
then MediaElement, OptionsElement, Ordering others (AssociationsElement,
AttributesElement, DetailsElement, LowestPriceInformationElementInterface,
LowestPriceInformationElement, MediaElement, PricingElement, ShippingElement,
TaxonomyElement, TranslationsElement, VariantsElement), ensuring all import
lines (e.g., AssociationsElement, AttributesElement, DetailsElement,
LowestPriceInformationElementInterface, LowestPriceInformationElement,
MediaElement, PricingElement, ShippingElement, TaxonomyElement, OptionsElement,
TranslationsElement, VariantsElement, VerticalMenuElement) follow PHP
alphabetical ordering.
src/Sylius/Behat/Resources/config/services/elements/admin.php (2)

14-33: use imports are not sorted alphabetically.

Multiple ordering violations: Account\ResetElement (line 16) should come before Crud\* imports (lines 14–15), and Sylius\Behat\Service\Helper\AutocompleteHelperInterface (line 21, Service\ namespace) should follow all Element\ imports. Within Admin\, alphabetical order would be: Account < CatalogPromotion < Channel < Crud < Notifications < Promotion < Taxon < TopBar.

As per coding guidelines: "Sort PHP use imports alphabetically."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Resources/config/services/elements/admin.php` around lines
14 - 33, The imports are not alphabetically ordered; reorder the use statements
so all Sylius\Behat\Element\* imports are sorted alphabetically by full
namespace segment (within Admin: Account, CatalogPromotion, Channel, Crud,
Notifications, Promotion, Taxon, TopBar) and ensure interface names come before
their implementations (e.g.,
DiscountedProductsCheckingPeriodInputElementInterface before
DiscountedProductsCheckingPeriodInputElement, LowestPriceFlagElementInterface
before LowestPriceFlagElement,
ExcludeTaxonsFromShowingLowestPriceInputElementInterface before its
implementation), specifically move ResetElement (Account\ResetElement) to appear
before Crud\FormElement/SearchFilterElement and place
AutocompleteHelperInterface
(Sylius\Behat\Service\Helper\AutocompleteHelperInterface) after all Element\
imports; apply the same alphabetical ordering to FilterElement and
FormElementInterface as part of this reorder.

74-178: Replace inline FQCNs with use imports.

Multiple service definitions use inline fully-qualified class names (e.g., \Sylius\Behat\Element\Admin\CatalogPromotion\FormElement::class at line 74, \Sylius\Behat\Element\Admin\ShippingMethod\FormElement::class at line 112, \Sylius\Behat\Element\Admin\Customer\FormElement::class at line 122, etc.) while others already use imported aliases. All non-global classes should be declared via use statements.

As per coding guidelines: "Use use statements for all non-global classes in PHP."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Resources/config/services/elements/admin.php` around lines
74 - 178, Several service definitions use inline FQCNs instead of imported class
names; replace those inline references with use imports and then use the
imported short class names in the service definitions. Specifically, add use
statements for classes seen in the diff such as
Sylius\Behat\Element\Admin\CatalogPromotion\FormElement,
Sylius\Behat\Element\Admin\TaxRate\FilterElement,
Sylius\Behat\Element\Admin\Promotion\FormElement,
Sylius\Behat\Element\Admin\ShippingMethod\FormElement,
Sylius\Behat\Element\Admin\ProductOption\FormElement,
Sylius\Behat\Element\Admin\Customer\FormElement,
Sylius\Behat\Element\Admin\Zone\FormElement,
Sylius\Behat\Element\Admin\Taxon\FormElement,
Sylius\Behat\Element\Admin\Taxon\ImageFormElement (ImageFormElement already
used), Sylius\Behat\Element\Admin\Taxon\TreeElement (TreeElement already used),
Sylius\Behat\Element\Admin\PromotionCoupon\FormElement,
Sylius\Behat\Element\Admin\TaxCategory\FormElement,
Sylius\Behat\Element\Admin\Currency\FormElement,
Sylius\Behat\Element\Admin\Locale\FormElement,
Sylius\Behat\Element\Admin\ExchangeRate\FormElement,
Sylius\Behat\Element\Admin\CustomerGroup\FormElement (and any other
fully-qualified names in this file), then update each ->set(...) call to
reference the imported class name (remove leading backslashes and inline FQCNs)
so all non-global classes are declared via use statements per the coding
guideline.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/Sylius/Behat/Resources/config/services/elements/admin.php`:
- Around line 14-33: The imports are not alphabetically ordered; reorder the use
statements so all Sylius\Behat\Element\* imports are sorted alphabetically by
full namespace segment (within Admin: Account, CatalogPromotion, Channel, Crud,
Notifications, Promotion, Taxon, TopBar) and ensure interface names come before
their implementations (e.g.,
DiscountedProductsCheckingPeriodInputElementInterface before
DiscountedProductsCheckingPeriodInputElement, LowestPriceFlagElementInterface
before LowestPriceFlagElement,
ExcludeTaxonsFromShowingLowestPriceInputElementInterface before its
implementation), specifically move ResetElement (Account\ResetElement) to appear
before Crud\FormElement/SearchFilterElement and place
AutocompleteHelperInterface
(Sylius\Behat\Service\Helper\AutocompleteHelperInterface) after all Element\
imports; apply the same alphabetical ordering to FilterElement and
FormElementInterface as part of this reorder.
- Around line 74-178: Several service definitions use inline FQCNs instead of
imported class names; replace those inline references with use imports and then
use the imported short class names in the service definitions. Specifically, add
use statements for classes seen in the diff such as
Sylius\Behat\Element\Admin\CatalogPromotion\FormElement,
Sylius\Behat\Element\Admin\TaxRate\FilterElement,
Sylius\Behat\Element\Admin\Promotion\FormElement,
Sylius\Behat\Element\Admin\ShippingMethod\FormElement,
Sylius\Behat\Element\Admin\ProductOption\FormElement,
Sylius\Behat\Element\Admin\Customer\FormElement,
Sylius\Behat\Element\Admin\Zone\FormElement,
Sylius\Behat\Element\Admin\Taxon\FormElement,
Sylius\Behat\Element\Admin\Taxon\ImageFormElement (ImageFormElement already
used), Sylius\Behat\Element\Admin\Taxon\TreeElement (TreeElement already used),
Sylius\Behat\Element\Admin\PromotionCoupon\FormElement,
Sylius\Behat\Element\Admin\TaxCategory\FormElement,
Sylius\Behat\Element\Admin\Currency\FormElement,
Sylius\Behat\Element\Admin\Locale\FormElement,
Sylius\Behat\Element\Admin\ExchangeRate\FormElement,
Sylius\Behat\Element\Admin\CustomerGroup\FormElement (and any other
fully-qualified names in this file), then update each ->set(...) call to
reference the imported class name (remove leading backslashes and inline FQCNs)
so all non-global classes are declared via use statements per the coding
guideline.

In
`@src/Sylius/Behat/Resources/config/services/elements/admin/product_attribute.php`:
- Around line 14-18: The use-imports in this file are not alphabetized; reorder
the imports so they are sorted alphabetically by full import string: place
Sylius\Behat\Element\Admin\ProductAttribute\FilterElement before
Sylius\Behat\Element\Admin\ProductAttribute\FormElement, and ensure
Sylius\Behat\Service\Helper\AutocompleteHelperInterface comes after the two
Element imports; keep the Symfony imports
(Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator
and the service function) in their proper alphabetical positions as well so all
use statements are fully sorted.

In `@src/Sylius/Behat/Resources/config/services/elements/admin/product.php`:
- Around line 14-23: Reorder the PHP use statements so they are alphabetically
sorted: move all Sylius\Behat\Element\Admin\Product\* imports
(AssociationsFormElement, AttributesFormElement, ChannelPricingsFormElement,
MediaFormElement, TaxonomyFormElement, TranslationsFormElement) before
Sylius\Behat\Element\Admin\ProductAssociationType\FormElement and place
Sylius\Behat\Service\Helper\AutocompleteHelperInterface after the Element
imports; ensure
Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator
and the service() import remain in correct alphabetical order relative to the
others so the entire block is alphabetized.

In `@src/Sylius/Behat/Resources/config/services/elements/product.php`:
- Around line 14-27: The use imports are out-of-order; reorder them
alphabetically and group related namespaces: place VerticalMenuElement
(IndexPage) before the ShowPage imports, then within ShowPage sort
alphabetically so DetailsElement is followed by
LowestPriceInformationElementInterface and LowestPriceInformationElement, then
MediaElement, OptionsElement, Ordering others (AssociationsElement,
AttributesElement, DetailsElement, LowestPriceInformationElementInterface,
LowestPriceInformationElement, MediaElement, PricingElement, ShippingElement,
TaxonomyElement, TranslationsElement, VariantsElement), ensuring all import
lines (e.g., AssociationsElement, AttributesElement, DetailsElement,
LowestPriceInformationElementInterface, LowestPriceInformationElement,
MediaElement, PricingElement, ShippingElement, TaxonomyElement, OptionsElement,
TranslationsElement, VariantsElement, VerticalMenuElement) follow PHP
alphabetical ordering.

In `@src/Sylius/Behat/Resources/config/services/elements/shop.php`:
- Around line 14-21: The use imports are not alphabetically ordered: move
MenuElement so imports follow alphabetical order relative to
CartWidgetElementInterface, CartWidgetElement, CheckoutSubtotalElementInterface,
CheckoutSubtotalElement; update the import block (affecting symbols MenuElement,
CartWidgetElementInterface, CartWidgetElement, CheckoutSubtotalElementInterface,
CheckoutSubtotalElement) so all use statements are sorted alphabetically to
comply with the project's coding guidelines.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (2)
src/Sylius/Behat/Resources/config/services/elements/common.php (1)

23-40: sylius.behat.element.browser and sylius.behat.element.save are missing explicit visibility.

shop.php and product.php both call $services->defaults()->public() and then mark each concrete service ->private(). common.php sets no defaults, so BrowserElement and SaveElement will use the container's default visibility (public in test environments, but inconsistent with the pattern in sibling files).

🔧 Proposed fix
 return static function (ContainerConfigurator $container) {
     $services = $container->services();
+
+    $services->defaults()->public();

     $services
         ->set('sylius.behat.element', Element::class)
         ->abstract()
         ->args([
             service('behat.mink.default_session'),
             service('behat.mink.parameters'),
         ])
     ;

     $services
         ->set('sylius.behat.element.browser', BrowserElement::class)
+        ->private()
         ->parent('sylius.behat.element')
     ;

     $services
         ->set('sylius.behat.element.save', SaveElement::class)
+        ->private()
         ->parent('sylius.behat.element')
     ;
 };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Resources/config/services/elements/common.php` around lines
23 - 40, The two service definitions sylius.behat.element.browser
(BrowserElement::class) and sylius.behat.element.save (SaveElement::class) lack
explicit visibility and will inherit inconsistent defaults; update both service
registrations to declare their visibility explicitly (e.g., append ->private()
to each ->set(...)->parent('sylius.behat.element') call) so they match the
visibility pattern used in sibling files.
src/Sylius/Behat/Resources/config/services/elements/admin/product.php (1)

25-68: Services are missing explicit ->private() visibility — inconsistent with sibling files.

shop.php and product.php both call $services->defaults()->public() and mark each concrete service ->private(). This file sets no defaults and no ->private(), making these services publicly visible by default, which is inconsistent. Consider aligning with the pattern used in the peer files.

🔧 Proposed fix
 return static function (ContainerConfigurator $container) {
     $services = $container->services();
+
+    $services->defaults()->public();

     $services
         ->set('sylius.behat.element.admin.product_association_type.form', FormElement::class)
+        ->private()
         ->parent('sylius.behat.element.admin.crud.form')
         ->args([service(AutocompleteHelperInterface::class)])
     ;
     // ... apply ->private() to each remaining service definition
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Resources/config/services/elements/admin/product.php` around
lines 25 - 68, The services in this file (e.g.
'sylius.behat.element.admin.product_association_type.form' ->
FormElement::class, 'sylius.behat.element.admin.product.association_form' ->
AssociationsFormElement::class, etc.) are left public by omission; make them
private to match sibling files by adding ->private() to each service definition
(or call $services->defaults()->private() before the ->set(...) blocks) so every
concrete service is explicitly private.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Sylius/Behat/Resources/config/services/elements/admin.php`:
- Around line 74-178: Multiple services use inline fully-qualified class names
(e.g. \Sylius\Behat\Element\Admin\CatalogPromotion\FormElement::class,
\Sylius\Behat\Element\Admin\TaxRate\FilterElement::class,
\Sylius\Behat\Element\Admin\Promotion\FormElement::class,
\Sylius\Behat\Element\Admin\ShippingMethod\FormElement::class,
\Sylius\Behat\Element\Admin\ProductOption\FormElement::class,
\Sylius\Behat\Element\Admin\Customer\FormElement::class,
\Sylius\Behat\Element\Admin\Taxon\FormElement::class,
\Sylius\Behat\Element\Admin\Taxon\ImageFormElement::class,
\Sylius\Behat\Element\Admin\Taxon\TreeElement::class,
\Sylius\Behat\Element\Admin\PromotionCoupon\FormElement::class,
\Sylius\Behat\Element\Admin\TaxCategory\FormElement::class,
\Sylius\Behat\Element\Admin\Currency\FormElement::class,
\Sylius\Behat\Element\Admin\Locale\FormElement::class,
\Sylius\Behat\Element\Admin\ExchangeRate\FormElement::class,
\Sylius\Behat\Element\Admin\CustomerGroup\FormElement::class) which violates the
guideline to use use-imports; add top-of-file use statements and alias
conflicting FormElement classes (e.g. use
Sylius\Behat\Element\Admin\CatalogPromotion\FormElement as
CatalogPromotionFormElement) and then replace each inline FQCN in the service
definitions with the corresponding alias (e.g.
CatalogPromotionFormElement::class), keeping existing service IDs and args
unchanged.
- Around line 14-33: The import block is not alphabetically ordered and mixes
class and function imports; reorder the Sylius\Behat\Element\* class imports by
their full namespace (e.g., place
Sylius\Behat\Element\Admin\Account\ResetElement, then
Admin\CatalogPromotion\FilterElement, then Admin\Channel\... entries, then
Admin\Crud\FormElement and Admin\Crud\Index\SearchFilterElement) and keep the
service/function import (service and Symfony function imports) in a separate
group after the class imports; ensure unique symbols from the diff (FormElement,
SearchFilterElement, ResetElement, FilterElement, AutocompleteHelperInterface,
service) appear in their correct alphabetical groups.

In
`@src/Sylius/Behat/Resources/config/services/elements/admin/product_attribute.php`:
- Around line 14-18: Reorder the PHP use imports to follow the project's
alphabetical and grouping rules: group class imports together (sort them
alphabetically) then function imports; specifically, place FilterElement before
FormElement (use Sylius\Behat\Element\Admin\ProductAttribute\FilterElement then
use Sylius\Behat\Element\Admin\ProductAttribute\FormElement), move
AutocompleteHelperInterface so it comes after the Element class imports (it
belongs with Sylius\Behat\Service imports), and keep ContainerConfigurator with
the class group while the function import service stays in the function/group
section; adjust the sequence accordingly to be fully alphabetized within each
group.

In `@src/Sylius/Behat/Resources/config/services/elements/admin/product.php`:
- Around line 14-23: Reorder the PHP use statements so they are alphabetized and
grouped by type (classes first, then functions); specifically, place
Sylius\Behat\Service\AutocompleteHelperInterface after the
Sylius\Behat\Element\* imports and alphabetize all
Sylius\Behat\Element\Admin\Product\* imports (AssociationsFormElement,
AttributesFormElement, ChannelPricingsFormElement, FormElement,
MediaFormElement, TaxonomyFormElement, TranslationsFormElement) in proper
alphabetical order, and ensure
Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator
comes with other class imports while the function import (service) remains in
the function group.

In `@src/Sylius/Behat/Resources/config/services/elements/product.php`:
- Around line 14-27: Reorder the PHP use imports so they are alphabetically
sorted and grouped by type: move IndexPage\VerticalMenuElement before all
ShowPage imports, place LowestPriceInformationElementInterface and
LowestPriceInformationElement with other L entries (before OptionsElement,
PricingElement, ShippingElement, TaxonomyElement, TranslationsElement, etc.),
and ensure OptionsElement, TaxonomyElement, PricingElement, ShippingElement,
TranslationsElement follow alphabetical order; update the import block
containing AssociationsElement, AttributesElement, DetailsElement, MediaElement,
TranslationsElement, PricingElement, ShippingElement, TaxonomyElement,
OptionsElement, VariantsElement, LowestPriceInformationElementInterface,
LowestPriceInformationElement, VerticalMenuElement accordingly.

In `@src/Sylius/Behat/Resources/config/services/elements/shop.php`:
- Around line 14-21: The use statements import order is not alphabetized: move
Sylius\Behat\Element\Shop\CartWidgetElementInterface and
Sylius\Behat\Element\Shop\CartWidgetElement to appear before
Sylius\Behat\Element\Shop\MenuElement so the Shop group is sorted alphabetically
(Cart* then Menu*); also ensure imports remain grouped by type (classes first,
then functions like service) and keep RegisterElement,
CheckoutSubtotalElementInterface/CheckoutSubtotalElement positions consistent
while applying the same alphabetical ordering rule.

---

Nitpick comments:
In `@src/Sylius/Behat/Resources/config/services/elements/admin/product.php`:
- Around line 25-68: The services in this file (e.g.
'sylius.behat.element.admin.product_association_type.form' ->
FormElement::class, 'sylius.behat.element.admin.product.association_form' ->
AssociationsFormElement::class, etc.) are left public by omission; make them
private to match sibling files by adding ->private() to each service definition
(or call $services->defaults()->private() before the ->set(...) blocks) so every
concrete service is explicitly private.

In `@src/Sylius/Behat/Resources/config/services/elements/common.php`:
- Around line 23-40: The two service definitions sylius.behat.element.browser
(BrowserElement::class) and sylius.behat.element.save (SaveElement::class) lack
explicit visibility and will inherit inconsistent defaults; update both service
registrations to declare their visibility explicitly (e.g., append ->private()
to each ->set(...)->parent('sylius.behat.element') call) so they match the
visibility pattern used in sibling files.

@NoResponseMate NoResponseMate force-pushed the behat/update-services-definition-to-php-elements branch from d204c5e to 281e055 Compare February 23, 2026 10:10
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
src/Sylius/Behat/Resources/config/services/elements/admin/product.php (1)

14-23: ⚠️ Potential issue | 🟡 Minor

use imports are not sorted alphabetically — unresolved from previous review.

All Sylius\Behat\Element\Admin\Product\* class imports should precede Sylius\Behat\Element\Admin\ProductAssociationType\FormElement (Product\ < ProductAssociationType\), and Sylius\Behat\Service\Helper\AutocompleteHelperInterface should follow all Sylius\Behat\Element\* imports (Element < Service).

♻️ Proposed fix
-use Sylius\Behat\Element\Admin\ProductAssociationType\FormElement;
-use Sylius\Behat\Service\Helper\AutocompleteHelperInterface;
 use Sylius\Behat\Element\Admin\Product\AssociationsFormElement;
 use Sylius\Behat\Element\Admin\Product\AttributesFormElement;
 use Sylius\Behat\Element\Admin\Product\ChannelPricingsFormElement;
 use Sylius\Behat\Element\Admin\Product\MediaFormElement;
 use Sylius\Behat\Element\Admin\Product\TaxonomyFormElement;
 use Sylius\Behat\Element\Admin\Product\TranslationsFormElement;
+use Sylius\Behat\Element\Admin\ProductAssociationType\FormElement;
+use Sylius\Behat\Service\Helper\AutocompleteHelperInterface;
 use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
 use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Resources/config/services/elements/admin/product.php` around
lines 14 - 23, The use imports in this file are out of alphabetical order;
reorder and group them so all Sylius\Behat\Element\Admin\Product\* imports
(AssociationsFormElement, AttributesFormElement, ChannelPricingsFormElement,
MediaFormElement, TaxonomyFormElement, TranslationsFormElement) appear before
Sylius\Behat\Element\Admin\ProductAssociationType\FormElement, and place
Sylius\Behat\Service\Helper\AutocompleteHelperInterface after the Element
imports; keep the function import (service) in its own group after class
imports. Ensure imports are alphabetized within their groups and that the
grouping follows classes first then functions/constants.
src/Sylius/Behat/Resources/config/services/elements/product.php (1)

14-27: ⚠️ Potential issue | 🟡 Minor

use imports are not sorted alphabetically — unresolved from previous review.

IndexPage\VerticalMenuElement (line 26) should precede all ShowPage\* imports (IndexPage < ShowPage). Within ShowPage\*, LowestPrice* (lines 24–25, L) should appear before MediaElement (line 17, M), and OptionsElement (line 22, O) before PricingElement (line 19, P) — which itself should precede ShippingElement (line 20), TaxonomyElement (line 21), and TranslationsElement (line 18).

♻️ Proposed fix
-use Sylius\Behat\Element\Product\ShowPage\AssociationsElement;
-use Sylius\Behat\Element\Product\ShowPage\AttributesElement;
-use Sylius\Behat\Element\Product\ShowPage\DetailsElement;
-use Sylius\Behat\Element\Product\ShowPage\MediaElement;
-use Sylius\Behat\Element\Product\ShowPage\TranslationsElement;
-use Sylius\Behat\Element\Product\ShowPage\PricingElement;
-use Sylius\Behat\Element\Product\ShowPage\ShippingElement;
-use Sylius\Behat\Element\Product\ShowPage\TaxonomyElement;
-use Sylius\Behat\Element\Product\ShowPage\OptionsElement;
-use Sylius\Behat\Element\Product\ShowPage\VariantsElement;
-use Sylius\Behat\Element\Product\ShowPage\LowestPriceInformationElementInterface;
-use Sylius\Behat\Element\Product\ShowPage\LowestPriceInformationElement;
-use Sylius\Behat\Element\Product\IndexPage\VerticalMenuElement;
+use Sylius\Behat\Element\Product\IndexPage\VerticalMenuElement;
+use Sylius\Behat\Element\Product\ShowPage\AssociationsElement;
+use Sylius\Behat\Element\Product\ShowPage\AttributesElement;
+use Sylius\Behat\Element\Product\ShowPage\DetailsElement;
+use Sylius\Behat\Element\Product\ShowPage\LowestPriceInformationElement;
+use Sylius\Behat\Element\Product\ShowPage\LowestPriceInformationElementInterface;
+use Sylius\Behat\Element\Product\ShowPage\MediaElement;
+use Sylius\Behat\Element\Product\ShowPage\OptionsElement;
+use Sylius\Behat\Element\Product\ShowPage\PricingElement;
+use Sylius\Behat\Element\Product\ShowPage\ShippingElement;
+use Sylius\Behat\Element\Product\ShowPage\TaxonomyElement;
+use Sylius\Behat\Element\Product\ShowPage\TranslationsElement;
+use Sylius\Behat\Element\Product\ShowPage\VariantsElement;
 use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Resources/config/services/elements/product.php` around lines
14 - 27, The use imports are not sorted alphabetically; reorder the class
imports so IndexPage\VerticalMenuElement appears before all ShowPage\* imports,
and within the ShowPage group place LowestPriceInformationElementInterface and
LowestPriceInformationElement (LowestPrice*) before MediaElement, place
OptionsElement before PricingElement, and ensure PricingElement comes before
ShippingElement, TaxonomyElement and TranslationsElement; also ensure imports
are grouped by type (classes) and duplicate imports removed so the list is
strictly alphabetized.
🧹 Nitpick comments (1)
src/Sylius/Behat/Resources/config/services/elements/product.php (1)

32-104: Redundant ->defaults()->public() + per-service ->private() pattern.

Setting defaults to public() (line 32) and then calling ->private() on every individual service has the same net result as simply setting defaults to private(). The current pattern requires adding ->private() to each new service added in future, creating unnecessary maintenance overhead.

♻️ Proposed simplification
-    $services->defaults()->public();
+    $services->defaults()->private();

     $services
         ->set('sylius.behat.element.product.show.associations', AssociationsElement::class)
-        ->private()
         ->parent('sylius.behat.element')
     ;

     $services
         ->set('sylius.behat.element.product.show.attributes', AttributesElement::class)
-        ->private()
         ->parent('sylius.behat.element')
     ;
     // ... repeat for all remaining services
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Resources/config/services/elements/product.php` around lines
32 - 104, The file sets $services->defaults()->public() then marks each service
private with ->private(); change the defaults call to
$services->defaults()->private() and remove the unnecessary per-service
->private() calls (for services like
'sylius.behat.element.product.show.associations',
'sylius.behat.element.product.show.attributes',
'sylius.behat.element.product.show.details',
'sylius.behat.element.product.show.media',
'sylius.behat.element.product.show.more_details',
'sylius.behat.element.product.show.pricing',
'sylius.behat.element.product.show.shipping',
'sylius.behat.element.product.show.taxonomy',
'sylius.behat.element.product.show.options',
'sylius.behat.element.product.show.variants', the
LowestPriceInformationElementInterface binding, and
'sylius.behat.element.product.index.vertical_menu') so they inherit the private
default and you no longer need to repeat ->private() on each ->set(...) call.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Sylius/Behat/Resources/config/services/elements/admin/product.php`:
- Around line 40-68: The service definitions are appending
AutocompleteHelperInterface to parent constructor args but
ChannelPricingsFormElement, TranslationsFormElement and
ProductAssociationType\FormElement do not accept that extra constructor
parameter; remove the ->args([service(AutocompleteHelperInterface::class)]) from
the service definitions for the services using ChannelPricingsFormElement and
TranslationsFormElement (service IDs:
sylius.behat.element.admin.product.channel_pricing_form and
sylius.behat.element.admin.product.translations_form) and likewise for the
ProductAssociationType\FormElement service, or alternatively add a matching
__construct(Session $session, $minkParameters, AutocompleteHelperInterface
$autocompleteHelper) to each of those classes (ChannelPricingsFormElement,
TranslationsFormElement, ProductAssociationType\FormElement) if they actually
require the helper.

---

Duplicate comments:
In `@src/Sylius/Behat/Resources/config/services/elements/admin/product.php`:
- Around line 14-23: The use imports in this file are out of alphabetical order;
reorder and group them so all Sylius\Behat\Element\Admin\Product\* imports
(AssociationsFormElement, AttributesFormElement, ChannelPricingsFormElement,
MediaFormElement, TaxonomyFormElement, TranslationsFormElement) appear before
Sylius\Behat\Element\Admin\ProductAssociationType\FormElement, and place
Sylius\Behat\Service\Helper\AutocompleteHelperInterface after the Element
imports; keep the function import (service) in its own group after class
imports. Ensure imports are alphabetized within their groups and that the
grouping follows classes first then functions/constants.

In `@src/Sylius/Behat/Resources/config/services/elements/product.php`:
- Around line 14-27: The use imports are not sorted alphabetically; reorder the
class imports so IndexPage\VerticalMenuElement appears before all ShowPage\*
imports, and within the ShowPage group place
LowestPriceInformationElementInterface and LowestPriceInformationElement
(LowestPrice*) before MediaElement, place OptionsElement before PricingElement,
and ensure PricingElement comes before ShippingElement, TaxonomyElement and
TranslationsElement; also ensure imports are grouped by type (classes) and
duplicate imports removed so the list is strictly alphabetized.

---

Nitpick comments:
In `@src/Sylius/Behat/Resources/config/services/elements/product.php`:
- Around line 32-104: The file sets $services->defaults()->public() then marks
each service private with ->private(); change the defaults call to
$services->defaults()->private() and remove the unnecessary per-service
->private() calls (for services like
'sylius.behat.element.product.show.associations',
'sylius.behat.element.product.show.attributes',
'sylius.behat.element.product.show.details',
'sylius.behat.element.product.show.media',
'sylius.behat.element.product.show.more_details',
'sylius.behat.element.product.show.pricing',
'sylius.behat.element.product.show.shipping',
'sylius.behat.element.product.show.taxonomy',
'sylius.behat.element.product.show.options',
'sylius.behat.element.product.show.variants', the
LowestPriceInformationElementInterface binding, and
'sylius.behat.element.product.index.vertical_menu') so they inherit the private
default and you no longer need to repeat ->private() on each ->set(...) call.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d204c5e and 281e055.

📒 Files selected for processing (13)
  • src/Sylius/Behat/Resources/config/services.php
  • src/Sylius/Behat/Resources/config/services/elements/admin.php
  • src/Sylius/Behat/Resources/config/services/elements/admin.xml
  • src/Sylius/Behat/Resources/config/services/elements/admin/product.php
  • src/Sylius/Behat/Resources/config/services/elements/admin/product.xml
  • src/Sylius/Behat/Resources/config/services/elements/admin/product_attribute.php
  • src/Sylius/Behat/Resources/config/services/elements/admin/product_attribute.xml
  • src/Sylius/Behat/Resources/config/services/elements/common.php
  • src/Sylius/Behat/Resources/config/services/elements/common.xml
  • src/Sylius/Behat/Resources/config/services/elements/product.php
  • src/Sylius/Behat/Resources/config/services/elements/product.xml
  • src/Sylius/Behat/Resources/config/services/elements/shop.php
  • src/Sylius/Behat/Resources/config/services/elements/shop.xml
💤 Files with no reviewable changes (6)
  • src/Sylius/Behat/Resources/config/services/elements/common.xml
  • src/Sylius/Behat/Resources/config/services/elements/shop.xml
  • src/Sylius/Behat/Resources/config/services/elements/product.xml
  • src/Sylius/Behat/Resources/config/services/elements/admin/product.xml
  • src/Sylius/Behat/Resources/config/services/elements/admin/product_attribute.xml
  • src/Sylius/Behat/Resources/config/services/elements/admin.xml
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/Sylius/Behat/Resources/config/services.php
  • src/Sylius/Behat/Resources/config/services/elements/common.php
  • src/Sylius/Behat/Resources/config/services/elements/admin/product_attribute.php
  • src/Sylius/Behat/Resources/config/services/elements/admin.php
  • src/Sylius/Behat/Resources/config/services/elements/shop.php

Comment on lines +40 to +68
$services
->set('sylius.behat.element.admin.product.attributes_form', AttributesFormElement::class)
->parent('sylius.behat.element.admin.crud.form')
->args([service(AutocompleteHelperInterface::class)])
;

$services
->set('sylius.behat.element.admin.product.channel_pricing_form', ChannelPricingsFormElement::class)
->parent('sylius.behat.element.admin.crud.form')
->args([service(AutocompleteHelperInterface::class)])
;

$services
->set('sylius.behat.element.admin.product.media_form', MediaFormElement::class)
->parent('sylius.behat.element.admin.crud.form')
->args([service(AutocompleteHelperInterface::class)])
;

$services
->set('sylius.behat.element.admin.product.taxonomy_form', TaxonomyFormElement::class)
->parent('sylius.behat.element.admin.crud.form')
->args([service(AutocompleteHelperInterface::class)])
;

$services
->set('sylius.behat.element.admin.product.translations_form', TranslationsFormElement::class)
->parent('sylius.behat.element.admin.crud.form')
->args([service(AutocompleteHelperInterface::class)])
;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# Find the file under review to understand context
echo "=== File under review ==="
cat -n "src/Sylius/Behat/Resources/config/services/elements/admin/product.php" | head -80

echo ""
echo "=== Looking for element class implementations ==="

# Search for the element classes mentioned in the review
for class in "AttributesFormElement" "ChannelPricingsFormElement" "MediaFormElement" "TaxonomyFormElement" "TranslationsFormElement"; do
  echo ""
  echo "--- $class ---"
  fd "$class.php" --type f
done

Repository: Sylius/Sylius

Length of output: 3775


🏁 Script executed:

#!/bin/bash

# Find FormElement class definitions with constructors
echo "=== FormElement constructors in Admin/Product ==="
fd "FormElement.php" --type f | grep -i admin | head -20 | while read file; do
  echo "File: $file"
  cat -n "$file" | head -50
  echo ""
done

Repository: Sylius/Sylius

Length of output: 36894


🏁 Script executed:

#!/bin/bash

# Search for BaseFormElement class and its constructor
echo "=== BaseFormElement constructor ==="
rg -n "class BaseFormElement" --type=php -A 30 | head -100

echo ""
echo "=== Parent service definition: sylius.behat.element.admin.crud.form ==="
rg -n "sylius\.behat\.element\.admin\.crud\.form" --type=php -B 2 -A 5 | head -50

Repository: Sylius/Sylius

Length of output: 5114


Remove AutocompleteHelperInterface injection from services whose classes don't accept it in their constructor.

The ->args([...]) on a child definition appends arguments to the parent's list. While AttributesFormElement, AssociationsFormElement, MediaFormElement, and TaxonomyFormElement explicitly accept AutocompleteHelperInterface as their third constructor parameter, three services do not:

  • ChannelPricingsFormElement (lines 46–50) does not override __construct; it inherits BaseFormElement's constructor, which only accepts (Session, $minkParameters).
  • TranslationsFormElement (lines 65–68) does not override __construct; same issue.
  • ProductAssociationType\FormElement (lines 28–32) does not override __construct; same issue.

Appending AutocompleteHelperInterface to these will cause a runtime "too many arguments" error when the container attempts instantiation. Either:

  1. Add __construct(Session, $minkParameters, AutocompleteHelperInterface $autocompleteHelper) to these three classes if they need the autocomplete helper, or
  2. Remove the ->args([service(AutocompleteHelperInterface::class)]) from their service definitions if they don't.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Resources/config/services/elements/admin/product.php` around
lines 40 - 68, The service definitions are appending AutocompleteHelperInterface
to parent constructor args but ChannelPricingsFormElement,
TranslationsFormElement and ProductAssociationType\FormElement do not accept
that extra constructor parameter; remove the
->args([service(AutocompleteHelperInterface::class)]) from the service
definitions for the services using ChannelPricingsFormElement and
TranslationsFormElement (service IDs:
sylius.behat.element.admin.product.channel_pricing_form and
sylius.behat.element.admin.product.translations_form) and likewise for the
ProductAssociationType\FormElement service, or alternatively add a matching
__construct(Session $session, $minkParameters, AutocompleteHelperInterface
$autocompleteHelper) to each of those classes (ChannelPricingsFormElement,
TranslationsFormElement, ProductAssociationType\FormElement) if they actually
require the helper.

@TheMilek TheMilek merged commit f1f803e into Sylius:2.3 Feb 23, 2026
55 of 67 checks passed
@NoResponseMate NoResponseMate deleted the behat/update-services-definition-to-php-elements branch February 24, 2026 15:13
@NoResponseMate NoResponseMate mentioned this pull request Feb 26, 2026
27 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Behat Issues and PRs aimed at improving Behat usage. Maintenance CI configurations, READMEs, releases, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants