[Behat] Update elements config from xml to php#18860
Conversation
📝 WalkthroughWalkthroughThis 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
❌ Preview Environment deleted from BunnyshellAvailable commands:
|
There was a problem hiding this comment.
🧹 Nitpick comments (6)
src/Sylius/Behat/Resources/config/services/elements/shop.php (1)
14-21:useimports are not sorted alphabetically.
MenuElement(line 15) should come after allCartWidget*andCheckoutSubtotal*imports. As per coding guidelines: "Sort PHPuseimports 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:useimports are not sorted alphabetically.
FilterElement(line 16) should precedeFormElement(line 14) (Filter<Form), andAutocompleteHelperInterface(fromSylius\Behat\Service\) should follow bothElement\imports.As per coding guidelines: "Sort PHP
useimports 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:useimports are not sorted alphabetically.
Sylius\Behat\Element\Admin\Product\*(lines 16–21) should precedeSylius\Behat\Element\Admin\ProductAssociationType\FormElement(line 14), andSylius\Behat\Service\Helper\AutocompleteHelperInterface(line 15, aService\namespace) should follow allElement\imports.As per coding guidelines: "Sort PHP
useimports 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:useimports are not sorted alphabetically.Within the
ShowPagenamespace,TranslationsElement(T) appears beforePricingElement(P),OptionsElement(O) appears afterShippingElement/TaxonomyElement, and theLowestPrice*imports should be grouped betweenDetailsElementandMediaElement.VerticalMenuElement(fromIndexPage, which sorts beforeShowPage) should also precede theShowPageimports.As per coding guidelines: "Sort PHP
useimports 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:useimports are not sorted alphabetically.Multiple ordering violations:
Account\ResetElement(line 16) should come beforeCrud\*imports (lines 14–15), andSylius\Behat\Service\Helper\AutocompleteHelperInterface(line 21,Service\namespace) should follow allElement\imports. WithinAdmin\, alphabetical order would be:Account < CatalogPromotion < Channel < Crud < Notifications < Promotion < Taxon < TopBar.As per coding guidelines: "Sort PHP
useimports 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 withuseimports.Multiple service definitions use inline fully-qualified class names (e.g.,
\Sylius\Behat\Element\Admin\CatalogPromotion\FormElement::classat line 74,\Sylius\Behat\Element\Admin\ShippingMethod\FormElement::classat line 112,\Sylius\Behat\Element\Admin\Customer\FormElement::classat line 122, etc.) while others already use imported aliases. All non-global classes should be declared viausestatements.As per coding guidelines: "Use
usestatements 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.
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (2)
src/Sylius/Behat/Resources/config/services/elements/common.php (1)
23-40:sylius.behat.element.browserandsylius.behat.element.saveare missing explicit visibility.
shop.phpandproduct.phpboth call$services->defaults()->public()and then mark each concrete service->private().common.phpsets no defaults, soBrowserElementandSaveElementwill 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.phpandproduct.phpboth 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.
src/Sylius/Behat/Resources/config/services/elements/admin/product_attribute.php
Show resolved
Hide resolved
d204c5e to
281e055
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (2)
src/Sylius/Behat/Resources/config/services/elements/admin/product.php (1)
14-23:⚠️ Potential issue | 🟡 Minor
useimports are not sorted alphabetically — unresolved from previous review.All
Sylius\Behat\Element\Admin\Product\*class imports should precedeSylius\Behat\Element\Admin\ProductAssociationType\FormElement(Product\<ProductAssociationType\), andSylius\Behat\Service\Helper\AutocompleteHelperInterfaceshould follow allSylius\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
useimports 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
useimports are not sorted alphabetically — unresolved from previous review.
IndexPage\VerticalMenuElement(line 26) should precede allShowPage\*imports (IndexPage<ShowPage). WithinShowPage\*,LowestPrice*(lines 24–25,L) should appear beforeMediaElement(line 17,M), andOptionsElement(line 22,O) beforePricingElement(line 19,P) — which itself should precedeShippingElement(line 20),TaxonomyElement(line 21), andTranslationsElement(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
useimports 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 toprivate(). 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
📒 Files selected for processing (13)
src/Sylius/Behat/Resources/config/services.phpsrc/Sylius/Behat/Resources/config/services/elements/admin.phpsrc/Sylius/Behat/Resources/config/services/elements/admin.xmlsrc/Sylius/Behat/Resources/config/services/elements/admin/product.phpsrc/Sylius/Behat/Resources/config/services/elements/admin/product.xmlsrc/Sylius/Behat/Resources/config/services/elements/admin/product_attribute.phpsrc/Sylius/Behat/Resources/config/services/elements/admin/product_attribute.xmlsrc/Sylius/Behat/Resources/config/services/elements/common.phpsrc/Sylius/Behat/Resources/config/services/elements/common.xmlsrc/Sylius/Behat/Resources/config/services/elements/product.phpsrc/Sylius/Behat/Resources/config/services/elements/product.xmlsrc/Sylius/Behat/Resources/config/services/elements/shop.phpsrc/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
| $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)]) | ||
| ; |
There was a problem hiding this comment.
🧩 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
doneRepository: 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 ""
doneRepository: 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 -50Repository: 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 inheritsBaseFormElement'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:
- Add
__construct(Session, $minkParameters, AutocompleteHelperInterface $autocompleteHelper)to these three classes if they need the autocomplete helper, or - 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.
Summary by CodeRabbit