Skip to content

[XML2PHP] PromotionBundle#18770

Merged
TheMilek merged 1 commit intoSylius:2.3from
crydotsnake:xml2php/promotion
Feb 4, 2026
Merged

[XML2PHP] PromotionBundle#18770
TheMilek merged 1 commit intoSylius:2.3from
crydotsnake:xml2php/promotion

Conversation

@crydotsnake
Copy link
Copy Markdown
Member

@crydotsnake crydotsnake commented Jan 31, 2026

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

Summary by CodeRabbit

  • New Features

    • Added a console command for generating promotion coupons.
    • Promotion generators, providers, processors, registries, form types and validators are now registered and publicly available for promotion workflows.
  • Chores

    • Migrated PromotionBundle service configuration from XML to PHP and consolidated integration/criteria/eligibility/forms/validators wiring.
    • Adjusted visibility of several promotion-related services.

@crydotsnake crydotsnake requested review from a team as code owners January 31, 2026 11:44
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 31, 2026

📝 Walkthrough

Walkthrough

Replaces XML-based Dependency Injection configuration for PromotionBundle with PHP ContainerConfigurator files: swaps XmlFileLoader → PhpFileLoader in the bundle extension, adds PHP service configurators under Resources/config (services, forms, validators, criteria, eligibility_checkers, integrations, console_command), removes corresponding XML files, and updates composer-require-checker whitelist.

Changes

Cohort / File(s) Summary
Extension Loader
src/Sylius/Bundle/PromotionBundle/DependencyInjection/SyliusPromotionExtension.php
Swapped XmlFileLoader import/usage for PhpFileLoader; updated loader to load .php config filenames instead of .xml.
Root Services
src/Sylius/Bundle/PromotionBundle/Resources/config/services.php, src/Sylius/Bundle/PromotionBundle/Resources/config/services.xml
Added comprehensive PHP service configurator registering generators, providers, processors, applicators, registries, and public/interface aliases; removed the XML counterpart.
Console Command
src/Sylius/Bundle/PromotionBundle/Resources/config/services/console_command.php, .../console_command.xml
Added PHP service sylius.console.command.generate_coupons wired to promotion repository and coupon generator; deleted XML definition.
Criteria Services
src/Sylius/Bundle/PromotionBundle/Resources/config/services/criteria.php, .../criteria.xml
Moved catalog promotion criteria (Enabled, DateRange) into PHP configurator with tagging; removed XML file.
Eligibility Checkers
src/Sylius/Bundle/PromotionBundle/Resources/config/services/eligibility_checkers.php, .../eligibility_checkers.xml
Converted many eligibility checker services, composite checkers, aliases and tags to PHP; deleted XML version.
Form Types
src/Sylius/Bundle/PromotionBundle/Resources/config/services/forms.php, .../forms.xml
Recreated full forms DI wiring in PHP: form types, validation-group params, tagged iterators, inline data mapper; removed large XML form configuration.
Validators
src/Sylius/Bundle/PromotionBundle/Resources/config/services/validators.php, .../validators.xml
Added PHP validator service registrations with validator.constraint_validator tags and aliases; removed XML validators file.
Doctrine ORM Integration
src/Sylius/Bundle/PromotionBundle/Resources/config/services/integrations/doctrine/orm.php, .../orm.xml
Replaced XML parameter mappings for repository classes with PHP ContainerConfigurator parameter bindings; removed XML integration file.
DI Helpers Whitelist
composer-require-checker.json
Inserted tagged_iterator into the public symbol whitelist near service/inline_service.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

DX, Maintenance

Suggested reviewers

  • TheMilek
  • GSadee

Poem

🐇 I swapped XML crumbs for PHP seeds today,
closures tuck services tidy in their tray.
Aliases hop, tagged iterators play,
loaders changed paws and hopped away.
A little rabbit cheers the new config way.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[XML2PHP] PromotionBundle' clearly and concisely identifies the primary change: converting XML configuration files to PHP format in the PromotionBundle.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 Jan 31, 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.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@src/Sylius/Bundle/PromotionBundle/Resources/config/services.php`:
- Around line 80-84: The ActivePromotionsProvider service is registered but not
aliased to the PreQualifiedPromotionsProviderInterface, which breaks autowiring;
add an alias from PreQualifiedPromotionsProviderInterface to the existing
service id 'sylius.provider.active_promotions' so code type-hinting
PreQualifiedPromotionsProviderInterface resolves to ActivePromotionsProvider
(i.e., create an alias for PreQualifiedPromotionsProviderInterface::class
pointing at 'sylius.provider.active_promotions' alongside the existing
ActivePromotionsProvider alias).

In
`@src/Sylius/Bundle/PromotionBundle/Resources/config/services/eligibility_checkers.php`:
- Around line 40-42: The closure static function (ContainerConfigurator
$container) defined in the services config should declare an explicit return
type to comply with project guidelines; change its signature to include : void
(i.e. static function (ContainerConfigurator $container): void) so the function
has an explicit return type while leaving the rest of the closure body
unchanged; this affects the closure used to register services such as
CompositePromotionCouponEligibilityChecker and
CompositePromotionEligibilityChecker.

In `@src/Sylius/Bundle/PromotionBundle/Resources/config/services/forms.php`:
- Around line 37-44: Add a new validation-groups parameter named
sylius.form.type.promotion_rule.validation_groups (value ['sylius']) alongside
the other form validation parameters, and update the PromotionRuleType service
configuration to reference this new parameter instead of
sylius.form.type.promotion_scope.validation_groups; locate the parameter block
in forms.php where other sylius.form.type.*.validation_groups are set and the
PromotionRuleType service/config entry (the service or class named
PromotionRuleType) to swap the validation_groups reference to the new
sylius.form.type.promotion_rule.validation_groups symbol.
🧹 Nitpick comments (6)
src/Sylius/Bundle/PromotionBundle/Resources/config/services/integrations/doctrine/orm.php (1)

20-20: Add explicit : void return type to the config closure.
Keeps return typing consistent with the PHP guidelines.

Proposed change
-return static function (ContainerConfigurator $container) {
+return static function (ContainerConfigurator $container): void {
src/Sylius/Bundle/PromotionBundle/Resources/config/services/criteria.php (1)

19-19: Add explicit : void return type to the config closure.
Keeps return typing consistent with the PHP guidelines.

Proposed change
-return static function (ContainerConfigurator $container) {
+return static function (ContainerConfigurator $container): void {
src/Sylius/Bundle/PromotionBundle/Resources/config/services/console_command.php (1)

18-18: Add explicit : void return type to the config closure.
Keeps return typing consistent with the PHP guidelines.

Proposed change
-return static function (ContainerConfigurator $container) {
+return static function (ContainerConfigurator $container): void {
src/Sylius/Bundle/PromotionBundle/Resources/config/services/validators.php (1)

29-29: Add explicit : void return type to the config closure.
Keeps return typing consistent with the PHP guidelines.

Proposed change
-return static function (ContainerConfigurator $container) {
+return static function (ContainerConfigurator $container): void {
src/Sylius/Bundle/PromotionBundle/Resources/config/services/eligibility_checkers.php (1)

28-28: Add explicit : void return type to the config closure.
Keeps return typing consistent with the PHP guidelines.

Proposed change
-return static function (ContainerConfigurator $container) {
+return static function (ContainerConfigurator $container): void {
src/Sylius/Bundle/PromotionBundle/Resources/config/services.php (1)

35-35: Add explicit : void return type to the config closure.
Keeps return typing consistent with the PHP guidelines.

Proposed change
-return static function (ContainerConfigurator $container) {
+return static function (ContainerConfigurator $container): void {

Comment on lines +80 to +84
$services->set('sylius.provider.active_promotions', ActivePromotionsProvider::class)
->args([service('sylius.repository.promotion')]);

$services->alias(ActivePromotionsProvider::class, 'sylius.provider.active_promotions');

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 | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Check for interface definition
rg -n -C2 "interface ActivePromotionsProviderInterface" --glob '*.php'

Repository: Sylius/Sylius

Length of output: 39


🏁 Script executed:

# Check for interface usage
rg -n "ActivePromotionsProviderInterface" --glob '*.php'

Repository: Sylius/Sylius

Length of output: 386


🏁 Script executed:

# Read the services.php file around line 35 to check the return type
head -50 src/Sylius/Bundle/PromotionBundle/Resources/config/services.php | tail -20

Repository: Sylius/Sylius

Length of output: 1103


🏁 Script executed:

# Get more context from the beginning of the services.php file
head -40 src/Sylius/Bundle/PromotionBundle/Resources/config/services.php

Repository: Sylius/Sylius

Length of output: 1909


🏁 Script executed:

# Search for the interface definition in the entire codebase
fd -e php -x grep -l "class.*ActivePromotionsProviderInterface\|interface.*ActivePromotionsProviderInterface" {} \;

Repository: Sylius/Sylius

Length of output: 39


🏁 Script executed:

# Look for the interface in the Component/Promotion package specifically
rg "ActivePromotionsProviderInterface" --glob '*.php' -B2 -A2

Repository: Sylius/Sylius

Length of output: 1254


🏁 Script executed:

# Check if there's a provider directory in Component/Promotion with the interface
fd -e php . | grep -i "promotion.*provider" | head -20

Repository: Sylius/Sylius

Length of output: 997


🏁 Script executed:

# Check what interface ActivePromotionsProvider actually implements
cat src/Sylius/Component/Promotion/Provider/ActivePromotionsProvider.php

Repository: Sylius/Sylius

Length of output: 826


🏁 Script executed:

# Also check PreQualifiedPromotionsProviderInterface to understand the hierarchy
cat src/Sylius/Component/Promotion/Provider/PreQualifiedPromotionsProviderInterface.php

Repository: Sylius/Sylius

Length of output: 653


🏁 Script executed:

# Check the full services.php file around lines 80-84 to see the current configuration
sed -n '75,90p' src/Sylius/Bundle/PromotionBundle/Resources/config/services.php

Repository: Sylius/Sylius

Length of output: 725


🏁 Script executed:

# Check if PreQualifiedPromotionsProviderInterface is already aliased anywhere
rg "PreQualifiedPromotionsProviderInterface" --glob '*.php' -B2 -A2 | head -40

Repository: Sylius/Sylius

Length of output: 4335


🏁 Script executed:

# Check the entire services.php to see all aliases and imports
rg "alias.*Promotions" src/Sylius/Bundle/PromotionBundle/Resources/config/services.php -B2 -A2

Repository: Sylius/Sylius

Length of output: 455


Add alias for PreQualifiedPromotionsProviderInterface.
The service only registers the concrete class. Since PreQualifiedPromotionsProviderInterface is the actual interface implemented by ActivePromotionsProvider and is type-hinted in production code, add an interface alias to maintain autowiring consistency with the pattern used elsewhere in this file.

Required change
use Sylius\Component\Promotion\Provider\ActivePromotionsProvider;
+use Sylius\Component\Promotion\Provider\PreQualifiedPromotionsProviderInterface;

     $services->alias(ActivePromotionsProvider::class, 'sylius.provider.active_promotions');
+    $services->alias(PreQualifiedPromotionsProviderInterface::class, 'sylius.provider.active_promotions');
🤖 Prompt for AI Agents
In `@src/Sylius/Bundle/PromotionBundle/Resources/config/services.php` around lines
80 - 84, The ActivePromotionsProvider service is registered but not aliased to
the PreQualifiedPromotionsProviderInterface, which breaks autowiring; add an
alias from PreQualifiedPromotionsProviderInterface to the existing service id
'sylius.provider.active_promotions' so code type-hinting
PreQualifiedPromotionsProviderInterface resolves to ActivePromotionsProvider
(i.e., create an alias for PreQualifiedPromotionsProviderInterface::class
pointing at 'sylius.provider.active_promotions' alongside the existing
ActivePromotionsProvider alias).

Comment on lines +40 to +42
$services->set('sylius.checker.promotion_coupon_eligibility', CompositePromotionCouponEligibilityChecker::class)
->args([[]]);

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 | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cat -n src/Sylius/Bundle/PromotionBundle/Resources/config/services/eligibility_checkers.php

Repository: Sylius/Sylius

Length of output: 4292


🏁 Script executed:

rg -n "CompositePromotion(Coupon)?EligibilityChecker" --glob="*.php" -A 10 -B 2 | head -80

Repository: Sylius/Sylius

Length of output: 11108


🏁 Script executed:

rg -n "eligibility_checker.*tag" --glob="*.php"

Repository: Sylius/Sylius

Length of output: 836


🏁 Script executed:

fd "CompilerPass" --glob="*.php" | xargs grep -l "eligibility_checker" 2>/dev/null

Repository: Sylius/Sylius

Length of output: 221


🏁 Script executed:

fd "CompositePromotionEligibilityCheckerPass.php" --type f

Repository: Sylius/Sylius

Length of output: 164


🏁 Script executed:

fd "CompositePromotionCouponEligibilityCheckerPass.php" --type f

Repository: Sylius/Sylius

Length of output: 170


🏁 Script executed:

cat -n src/Sylius/Bundle/PromotionBundle/DependencyInjection/Compiler/CompositePromotionEligibilityCheckerPass.php

Repository: Sylius/Sylius

Length of output: 1361


🏁 Script executed:

cat -n src/Sylius/Bundle/PromotionBundle/DependencyInjection/Compiler/CompositePromotionCouponEligibilityCheckerPass.php

Repository: Sylius/Sylius

Length of output: 1388


🏁 Script executed:

cat -n src/Sylius/Bundle/PromotionBundle/Resources/config/services/eligibility_checkers.php | sed -n '28p'

Repository: Sylius/Sylius

Length of output: 123


Add return type declaration : void to the closure on line 28.

The closure static function (ContainerConfigurator $container) is missing an explicit return type. It should be static function (ContainerConfigurator $container): void to comply with the guideline requiring type declarations for all return values.

Note: The empty arrays in the composite eligibility checkers (lines 40-42, 65-66) are intentional placeholders. They are properly populated at compile time via CompositePromotionEligibilityCheckerPass and CompositePromotionCouponEligibilityCheckerPass compiler passes, which collect all tagged services and wire them correctly.

🤖 Prompt for AI Agents
In
`@src/Sylius/Bundle/PromotionBundle/Resources/config/services/eligibility_checkers.php`
around lines 40 - 42, The closure static function (ContainerConfigurator
$container) defined in the services config should declare an explicit return
type to comply with project guidelines; change its signature to include : void
(i.e. static function (ContainerConfigurator $container): void) so the function
has an explicit return type while leaving the rest of the closure body
unchanged; this affects the closure used to register services such as
CompositePromotionCouponEligibilityChecker and
CompositePromotionEligibilityChecker.

Comment on lines +37 to +44
$parameters->set('sylius.form.type.catalog_promotion.validation_groups', ['sylius']);
$parameters->set('sylius.form.type.catalog_promotion_translation.validation_groups', ['sylius']);
$parameters->set('sylius.form.type.promotion.validation_groups', ['sylius']);
$parameters->set('sylius.form.type.promotion_translation.validation_groups', ['sylius']);
$parameters->set('sylius.form.type.promotion_action.validation_groups', ['sylius']);
$parameters->set('sylius.form.type.promotion_scope.validation_groups', ['sylius']);
$parameters->set('sylius.form.type.promotion_coupon.validation_groups', ['sylius']);
$parameters->set('sylius.form.type.promotion_coupon_generator_instruction.validation_groups', ['sylius']);
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 | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the file and see the full context
cat -n src/Sylius/Bundle/PromotionBundle/Resources/config/services/forms.php | head -120

Repository: Sylius/Sylius

Length of output: 6551


🏁 Script executed:

# Search for PromotionRuleType in the codebase
rg -n "PromotionRuleType" src/Sylius/Bundle/PromotionBundle -g '*.php' -A 5 -B 2

Repository: Sylius/Sylius

Length of output: 18312


🏁 Script executed:

# Search for validation groups references to promotion_scope and promotion_rule
rg -n "sylius\.form\.type\.promotion_(scope|rule)\.validation_groups" src/Sylius/Bundle -g '*.php' -g '*.xml' -A 2 -B 2

Repository: Sylius/Sylius

Length of output: 1480


Add missing promotion_rule validation group parameter and update PromotionRuleType to use it.

PromotionRuleType at line 100-106 incorrectly uses promotion_scope validation groups (line 103). Following the pattern established by other form types (catalog_promotion, promotion, promotion_action, etc.), add a dedicated sylius.form.type.promotion_rule.validation_groups parameter at line 42 and update the service configuration to use it.

Fix
 $parameters->set('sylius.form.type.promotion_action.validation_groups', ['sylius']);
+$parameters->set('sylius.form.type.promotion_rule.validation_groups', ['sylius']);
 $parameters->set('sylius.form.type.promotion_scope.validation_groups', ['sylius']);

And at lines 100-105:

 $services->set('sylius.form.type.promotion_rule', PromotionRuleType::class)
     ->args([
         '%sylius.model.promotion_rule.class%',
-        '%sylius.form.type.promotion_scope.validation_groups%',
+        '%sylius.form.type.promotion_rule.validation_groups%',
         service('sylius.form_registry.promotion_rule_checker'),
     ])
🤖 Prompt for AI Agents
In `@src/Sylius/Bundle/PromotionBundle/Resources/config/services/forms.php` around
lines 37 - 44, Add a new validation-groups parameter named
sylius.form.type.promotion_rule.validation_groups (value ['sylius']) alongside
the other form validation parameters, and update the PromotionRuleType service
configuration to reference this new parameter instead of
sylius.form.type.promotion_scope.validation_groups; locate the parameter block
in forms.php where other sylius.form.type.*.validation_groups are set and the
PromotionRuleType service/config entry (the service or class named
PromotionRuleType) to swap the validation_groups reference to the new
sylius.form.type.promotion_rule.validation_groups symbol.

Comment on lines +20 to +23
$parameters = $container->parameters();

$services->defaults()
->public();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
$parameters = $container->parameters();
$services->defaults()
->public();

->args([
service('sylius.repository.promotion'),
service('sylius.generator.promotion_coupon'),
])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
])
])
->public()


return static function (ContainerConfigurator $container) {
$services = $container->services();
$parameters = $container->parameters();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
$parameters = $container->parameters();


return static function (ContainerConfigurator $container) {
$services = $container->services();
$parameters = $container->parameters();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
$parameters = $container->parameters();


return static function (ContainerConfigurator $container) {
$services = $container->services();
$parameters = $container->parameters();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
$parameters = $container->parameters();

Comment on lines +36 to +38
$services = $container->services();
$parameters = $container->parameters();
$container->import('services/*.php');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
$services = $container->services();
$parameters = $container->parameters();
$container->import('services/*.php');
$container->import('services/*.php');
$services = $container->services();

@crydotsnake crydotsnake force-pushed the xml2php/promotion branch 2 times, most recently from b0b630d to 051adcf Compare February 4, 2026 08:24
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: 2

🤖 Fix all issues with AI agents
In `@src/Sylius/Bundle/PromotionBundle/Resources/config/services/forms.php`:
- Line 34: The exported config closure in services.php currently lacks an
explicit return type; update the anonymous static function signature "static
function (ContainerConfigurator $container)" to declare a void return type
(i.e., "static function (ContainerConfigurator $container): void") so it
conforms to the return-type coding guideline; ensure only the signature is
changed and the function body and ContainerConfigurator usage remain untouched.

In `@src/Sylius/Bundle/PromotionBundle/Resources/config/services/validators.php`:
- Around line 67-73: The service IDs are misspelled as "promotion_role_group"
and "promotion_role_type"; update them to "promotion_rule_group" and
"promotion_rule_type" to match the validator classes PromotionRuleGroupValidator
and PromotionRuleTypeValidator and the constraint aliases
sylius_promotion_rule_group / sylius_promotion_rule_type, and then search for
any other references to the old service IDs to update them accordingly so
configuration and usage remain consistent.
🧹 Nitpick comments (3)
src/Sylius/Bundle/PromotionBundle/Resources/config/services/console_command.php (1)

18-29: Add : void return type to the closure.

The closure is missing an explicit return type declaration. Per coding guidelines, all return values should have type declarations.

Suggested fix
-return static function (ContainerConfigurator $container) {
+return static function (ContainerConfigurator $container): void {
     $services = $container->services();
src/Sylius/Bundle/PromotionBundle/Resources/config/services/validators.php (1)

29-77: Add : void return type to the closure.

The closure is missing an explicit return type declaration. Per coding guidelines, all return values should have type declarations.

Suggested fix
-return static function (ContainerConfigurator $container) {
+return static function (ContainerConfigurator $container): void {
     $services = $container->services();
src/Sylius/Bundle/PromotionBundle/Resources/config/services.php (1)

35-108: Add : void return type to the closure.

The closure is missing an explicit return type declaration. Per coding guidelines, all return values should have type declarations.

Suggested fix
-return static function (ContainerConfigurator $container) {
+return static function (ContainerConfigurator $container): void {
     $services = $container->services();

use Sylius\Component\Promotion\Generator\PromotionCouponGeneratorInstruction;
use Symfony\Component\Form\Extension\Core\DataMapper\DataMapper;

return static function (ContainerConfigurator $container) {
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 | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check how other service PHP configs declare the ContainerConfigurator closure
rg -n "return static function \(ContainerConfigurator" src/Sylius/Bundle -g '*.php' -C 2

Repository: Sylius/Sylius

Length of output: 15898


Add an explicit void return type to the config closure.

The closure function should declare its return type in accordance with the coding guideline requiring type declarations for all return values.

Suggested change
-return static function (ContainerConfigurator $container) {
+return static function (ContainerConfigurator $container): void {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return static function (ContainerConfigurator $container) {
return static function (ContainerConfigurator $container): void {
🤖 Prompt for AI Agents
In `@src/Sylius/Bundle/PromotionBundle/Resources/config/services/forms.php` at
line 34, The exported config closure in services.php currently lacks an explicit
return type; update the anonymous static function signature "static function
(ContainerConfigurator $container)" to declare a void return type (i.e., "static
function (ContainerConfigurator $container): void") so it conforms to the
return-type coding guideline; ensure only the signature is changed and the
function body and ContainerConfigurator usage remain untouched.

Comment on lines +67 to +73
$services->set('sylius.validator.promotion_role_group', PromotionRuleGroupValidator::class)
->args(['%sylius.promotion.promotion_rule.validation_groups%'])
->tag('validator.constraint_validator', ['alias' => 'sylius_promotion_rule_group']);

$services->set('sylius.validator.promotion_role_type', PromotionRuleTypeValidator::class)
->args(['%sylius.promotion_rules%'])
->tag('validator.constraint_validator', ['alias' => 'sylius_promotion_rule_type']);
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 | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

rg -n "sylius\.validator\.promotion_r[ou][lu]e_(group|type)" --glob '*.php' --glob '*.xml' --glob '*.yaml' --glob '*.yml'

Repository: Sylius/Sylius

Length of output: 402


🏁 Script executed:

# Also search for references to the aliases in the tags
rg -n "sylius_promotion_rule_(group|type)" --glob '*.php' --glob '*.xml' --glob '*.yaml' --glob '*.yml'

Repository: Sylius/Sylius

Length of output: 651


🏁 Script executed:

# Find the validator class files to confirm the class names
fd -e php "PromotionRule(Group|Type)Validator"

Repository: Sylius/Sylius

Length of output: 378


🏁 Script executed:

# Check the content around lines 67-73 in the actual file to see current state
sed -n '60,80p' src/Sylius/Bundle/PromotionBundle/Resources/config/services/validators.php

Repository: Sylius/Sylius

Length of output: 1179


Fix typo in service IDs: "role" should be "rule".

The service IDs use promotion_role_group and promotion_role_type, which is inconsistent with the validator class names (PromotionRuleGroupValidator, PromotionRuleTypeValidator) and the constraint aliases. Although the aliases are correct and ensure the validators work, the service ID naming should match the class names for consistency.

Suggested fix
-    $services->set('sylius.validator.promotion_role_group', PromotionRuleGroupValidator::class)
+    $services->set('sylius.validator.promotion_rule_group', PromotionRuleGroupValidator::class)
         ->args(['%sylius.promotion.promotion_rule.validation_groups%'])
         ->tag('validator.constraint_validator', ['alias' => 'sylius_promotion_rule_group']);

-    $services->set('sylius.validator.promotion_role_type', PromotionRuleTypeValidator::class)
+    $services->set('sylius.validator.promotion_rule_type', PromotionRuleTypeValidator::class)
         ->args(['%sylius.promotion_rules%'])
         ->tag('validator.constraint_validator', ['alias' => 'sylius_promotion_rule_type']);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$services->set('sylius.validator.promotion_role_group', PromotionRuleGroupValidator::class)
->args(['%sylius.promotion.promotion_rule.validation_groups%'])
->tag('validator.constraint_validator', ['alias' => 'sylius_promotion_rule_group']);
$services->set('sylius.validator.promotion_role_type', PromotionRuleTypeValidator::class)
->args(['%sylius.promotion_rules%'])
->tag('validator.constraint_validator', ['alias' => 'sylius_promotion_rule_type']);
$services->set('sylius.validator.promotion_rule_group', PromotionRuleGroupValidator::class)
->args(['%sylius.promotion.promotion_rule.validation_groups%'])
->tag('validator.constraint_validator', ['alias' => 'sylius_promotion_rule_group']);
$services->set('sylius.validator.promotion_rule_type', PromotionRuleTypeValidator::class)
->args(['%sylius.promotion.promotion_rules%'])
->tag('validator.constraint_validator', ['alias' => 'sylius_promotion_rule_type']);
🤖 Prompt for AI Agents
In `@src/Sylius/Bundle/PromotionBundle/Resources/config/services/validators.php`
around lines 67 - 73, The service IDs are misspelled as "promotion_role_group"
and "promotion_role_type"; update them to "promotion_rule_group" and
"promotion_rule_type" to match the validator classes PromotionRuleGroupValidator
and PromotionRuleTypeValidator and the constraint aliases
sylius_promotion_rule_group / sylius_promotion_rule_type, and then search for
any other references to the old service IDs to update them accordingly so
configuration and usage remain consistent.

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: 3

🤖 Fix all issues with AI agents
In `@src/Sylius/Bundle/PromotionBundle/Resources/config/services.php`:
- Around line 35-36: The closure returned by the file uses the signature "return
static function (ContainerConfigurator $container)" but lacks an explicit return
type; update the anonymous configurator function signature to declare a void
return type (i.e., add ": void") so it becomes "return static function
(ContainerConfigurator $container): void" to match coding guidelines and
indicate it does not return a value.

In `@src/Sylius/Bundle/PromotionBundle/Resources/config/services/criteria.php`:
- Around line 19-20: The returned static configurator closure should declare an
explicit void return type to satisfy coding guidelines; update the anonymous
function returned (the static function accepting ContainerConfigurator
$container) to have a ": void" return type so the signature becomes a static
function(ContainerConfigurator $container): void, keeping the
ContainerConfigurator parameter and body unchanged.

In `@src/Sylius/Bundle/PromotionBundle/Resources/config/services/validators.php`:
- Around line 29-30: Update the returned static closure to include an explicit
void return type: modify the anonymous function signature that currently reads
"return static function (ContainerConfigurator $container)" to "return static
function (ContainerConfigurator $container): void" so the closure conforms to
the project's type-declaration guidelines; ensure the change targets the closure
that assigns $services = $container->services() in validators.php.

Comment on lines +35 to +36
return static function (ContainerConfigurator $container) {
$services = $container->services();
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 | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Check if the file exists and read the relevant section
fd -t f "services.php" --path "*/PromotionBundle/Resources/config/*"

Repository: Sylius/Sylius

Length of output: 290


🏁 Script executed:

# Read the file to see lines around 35-36
cat -n src/Sylius/Bundle/PromotionBundle/Resources/config/services.php | head -50

Repository: Sylius/Sylius

Length of output: 2816


Add explicit : void return type to the configurator closure.

This closure performs only service configuration without returning a value, and the coding guidelines require type declarations for all return values in PHP code.

Suggested change
-return static function (ContainerConfigurator $container) {
+return static function (ContainerConfigurator $container): void {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return static function (ContainerConfigurator $container) {
$services = $container->services();
return static function (ContainerConfigurator $container): void {
$services = $container->services();
🤖 Prompt for AI Agents
In `@src/Sylius/Bundle/PromotionBundle/Resources/config/services.php` around lines
35 - 36, The closure returned by the file uses the signature "return static
function (ContainerConfigurator $container)" but lacks an explicit return type;
update the anonymous configurator function signature to declare a void return
type (i.e., add ": void") so it becomes "return static function
(ContainerConfigurator $container): void" to match coding guidelines and
indicate it does not return a value.

Comment on lines +19 to +20
return static function (ContainerConfigurator $container) {
$services = $container->services();
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 | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's check if the file exists and read the context around lines 19-20
cat -n src/Sylius/Bundle/PromotionBundle/Resources/config/services/criteria.php

Repository: Sylius/Sylius

Length of output: 1081


🏁 Script executed:

# Search for similar configurator closures in the codebase to see if void return type is standard
rg -A 3 'return static function \(ContainerConfigurator' --type php -m 10

Repository: Sylius/Sylius

Length of output: 18036


🏁 Script executed:

# Check if there are other similar service configuration files that may show the pattern
fd -e php -path '*/Resources/config/services/*' | head -20 | xargs -I {} sh -c 'echo "=== {} ===" && head -n 25 {}'

Repository: Sylius/Sylius

Length of output: 225


Add explicit : void return type to the configurator closure.

This keeps return types explicit as required by coding guidelines: "Add type declarations for all properties, arguments, and return values in PHP code."

✅ Suggested change
-return static function (ContainerConfigurator $container) {
+return static function (ContainerConfigurator $container): void {
🤖 Prompt for AI Agents
In `@src/Sylius/Bundle/PromotionBundle/Resources/config/services/criteria.php`
around lines 19 - 20, The returned static configurator closure should declare an
explicit void return type to satisfy coding guidelines; update the anonymous
function returned (the static function accepting ContainerConfigurator
$container) to have a ": void" return type so the signature becomes a static
function(ContainerConfigurator $container): void, keeping the
ContainerConfigurator parameter and body unchanged.

Comment on lines +29 to +30
return static function (ContainerConfigurator $container) {
$services = $container->services();
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 | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "validators.php" | grep -E "PromotionBundle.*config/services"

Repository: Sylius/Sylius

Length of output: 133


🏁 Script executed:

cat -n src/Sylius/Bundle/PromotionBundle/Resources/config/services/validators.php | head -50

Repository: Sylius/Sylius

Length of output: 3100


Add explicit : void return type to the configurator closure.

The closure lacks an explicit return type declaration. Per coding guidelines: Add type declarations for all properties, arguments, and return values in PHP code.

✅ Suggested change
-return static function (ContainerConfigurator $container) {
+return static function (ContainerConfigurator $container): void {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return static function (ContainerConfigurator $container) {
$services = $container->services();
return static function (ContainerConfigurator $container): void {
$services = $container->services();
🤖 Prompt for AI Agents
In `@src/Sylius/Bundle/PromotionBundle/Resources/config/services/validators.php`
around lines 29 - 30, Update the returned static closure to include an explicit
void return type: modify the anonymous function signature that currently reads
"return static function (ContainerConfigurator $container)" to "return static
function (ContainerConfigurator $container): void" so the closure conforms to
the project's type-declaration guidelines; ensure the change targets the closure
that assigns $services = $container->services() in validators.php.

@TheMilek TheMilek merged commit 91a65b7 into Sylius:2.3 Feb 4, 2026
35 of 36 checks passed
This was referenced Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants