Skip to content

[XML2PHP] Api#18493

Merged
TheMilek merged 2 commits intoSylius:2.3from
loic425:xml2php/api
Feb 6, 2026
Merged

[XML2PHP] Api#18493
TheMilek merged 2 commits intoSylius:2.3from
loic425:xml2php/api

Conversation

@loic425
Copy link
Copy Markdown
Member

@loic425 loic425 commented Oct 31, 2025

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

Summary by CodeRabbit

  • New Features
    • Expanded API surface: new controllers, richer filters, additional state providers, more serializers, validators, command/query handlers, payment configuration and state processors — enabling more robust admin and shop API behaviors.
  • Chores
    • Migrated service configuration from XML to PHP for consistency.
    • Reordered dependency checker entries (no functional change).

@loic425 loic425 requested review from a team as code owners October 31, 2025 14:34
@probot-autolabeler probot-autolabeler bot added the API APIs related issues and PRs. label Oct 31, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Oct 31, 2025

📝 Walkthrough

Walkthrough

Replaces XML Symfony DI configs with PHP equivalents across the Sylius ApiBundle (many services, filters, providers, resolvers, serializers, validators, state processors, controllers, handlers, subscribers) and updates the bundle extension to load .php files; also reorders four entries in composer-require-checker.json.

Changes

Cohort / File(s) Summary
Extension loader
src/Sylius/Bundle/ApiBundle/DependencyInjection/SyliusApiExtension.php
Switched loader from XmlFileLoader to PhpFileLoader and changed loaded config filenames from .xml to .php (including swagger integration).
Manifest
composer-require-checker.json
Reordered four entries in public symbol-whitelist (no semantic changes).
Root services
src/Sylius/Bundle/ApiBundle/Resources/config/services.php, src/Sylius/Bundle/ApiBundle/Resources/config/services.xml
Migrated core service wiring (mappers, listeners, converters, aliases) from XML to PHP; XML file removed.
Integrations / OpenAPI
src/Sylius/Bundle/ApiBundle/Resources/config/integrations/swagger.php, .../swagger.xml
Recreated OpenAPI factory decorator and many documentation modifier services in PHP; XML variant removed.
API Platform decorators & routing
src/Sylius/Bundle/ApiBundle/Resources/config/services/api_platform.php, .../api_platform.xml
Added PHP decorators (IRI converter, API loader, metadata collection factories, hydra normalizer) and parameter; XML removed.
Serializers & normalizers
src/Sylius/Bundle/ApiBundle/Resources/config/services/serializers.php, .../serializers.xml
Moved many serializer normalizer/denormalizer service registrations and tags from XML to PHP; XML removed.
Validators
src/Sylius/Bundle/ApiBundle/Resources/config/services/validator.php, .../validator.xml
Ported large set of constraint validators and validation-group generators to PHP; XML removed.
State processors
src/Sylius/Bundle/ApiBundle/Resources/config/services/state_processors.php, .../state_processors.xml
Converted numerous api_platform state processors and decorators to PHP; XML removed.
Handlers (commands & queries)
src/Sylius/Bundle/ApiBundle/Resources/config/services/command_handlers.php, .../query_handlers.php, .../*.xml
Registered command and query handler services as PHP DI configs (messenger handlers); XML files removed.
Context builders & contexts
src/Sylius/Bundle/ApiBundle/Resources/config/services/context_builders.php, services/contexts.php, .../*.xml
Migrated decorated serializer context builders and user/cart context services to PHP; XML removed.
State providers (admin & shop)
src/Sylius/Bundle/ApiBundle/Resources/config/services/admin/state_providers.php, .../shop/state_providers.php, .../*.xml
Moved many api_platform state provider service definitions for admin and shop to PHP; XML files removed.
Filters (admin & shop)
src/Sylius/Bundle/ApiBundle/Resources/config/services/admin/filters.php, services/shop/filters.php, .../*.xml
Rewrote numerous API Platform filter service definitions (search, order, custom filters) in PHP; XML files removed.
Doctrine query extensions
src/Sylius/Bundle/ApiBundle/Resources/config/services/extensions.php, .../extensions.xml
Converted many Doctrine ORM query extension services and a decorator to PHP; XML removed.
Providers, resolvers, section resolvers
src/Sylius/Bundle/ApiBundle/Resources/config/services/providers.php, resolvers.php, section_resolver.php, .../*.xml
Moved path-prefix, image-filters, adjustment-order providers and operation/URI resolvers to PHP; XML removed.
Controllers, creators, applicators, payments, events, subscribers
src/Sylius/Bundle/ApiBundle/Resources/config/services/controllers.php, creators.php, applicators.php, payments.php, event_handlers.php, event_subscribers.php, .../*.xml
Replaced many controller, creator, applicator, payment controller, event handler and subscriber DI entries with PHP counterparts; corresponding XML files removed.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

DX

Suggested reviewers

  • GSadee

Poem

🐰 I hopped through configs, old XML trees,
I nudged them gently into PHP breeze.
Services lined up, decorators in tow,
Whitelist shuffled — the repo now glows.
Carrot for reviewers, quick as my toes. 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
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.
Title check ❓ Inconclusive The title '[XML2PHP] Api' is vague and non-descriptive, using a generic transformation pattern without clarifying the scope or specific changes made to the API bundle. Replace with a more descriptive title such as 'Convert API bundle service configuration from XML to PHP' to clearly indicate the main change and scope.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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 Oct 31, 2025

❌ Preview Environment deleted from Bunnyshell

Available commands:

  • 🚀 /bns:deploy to redeploy the environment

@Rafikooo Rafikooo changed the base branch from 2.2 to 2.3 February 5, 2026 14:58
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: 14

🤖 Fix all issues with AI agents
In
`@src/Sylius/Bundle/ApiBundle/Resources/config/services/admin/state_providers.php`:
- Around line 1-2: Add the PHP strict types declaration to the top of the file
by inserting declare(strict_types=1); as the first non-shebang line in
src/Sylius/Bundle/ApiBundle/Resources/config/services/admin/state_providers.php
so the file begins with the strict types directive per coding guidelines; ensure
it appears before any other PHP code or comments.

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/applicators.php`:
- Around line 1-5: Add a file-level declare(strict_types=1); at the top and add
a void return type to the returned configurator closure; specifically, insert
declare(strict_types=1); after the opening <?php tag and change the returned
static function signature from static function(ContainerConfigurator $container)
to static function(ContainerConfigurator $container): void so the configurator
closure has an explicit void return type and the file uses strict types.
- Around line 11-34: Replace string literal class names and interface names with
::class constants and add corresponding use statements; for each service
definition (e.g., the service id
'sylius_api.applicator.archiving_shipping_method' that references
ArchivingShippingMethodApplicator) change the second argument from the FQCN
string to ArchivingShippingMethodApplicator::class and update the matching alias
to ArchivingShippingMethodApplicatorInterface::class, repeating the change for
OrderStateMachineTransitionApplicator, PaymentStateMachineTransitionApplicator,
ProductReviewStateMachineTransitionApplicator, and ArchivingPromotionApplicator;
keep the existing constructor args (service('clock') and
service('sylius_abstraction.state_machine')) unchanged and ensure you import all
six applicator and interface types with use statements at the top of the file.

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/command_handlers.php`:
- Around line 1-5: Add a strict types declaration and fix PSR-12 spacing: insert
declare(strict_types=1); as the first statement after the opening <?php tag, and
change the anonymous function signature from "return static
function(ContainerConfigurator $container) {" to include a space after
"function" (i.e., "return static function (ContainerConfigurator $container) {")
so the file follows strict typing and PSR-12 spacing rules.

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/contexts.php`:
- Around line 1-2: Add a strict types declaration at the top of the PHP file by
inserting declare(strict_types=1); after the opening <?php tag, and add an
explicit return type to the service configuration closure (the static function
accepting ContainerConfigurator $containerConfigurator) — e.g. append the
appropriate return type such as : void to that closure signature so the file
follows the project's strict typing and function return-type conventions.

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/creators.php`:
- Around line 1-2: Add the strict types declaration at the top of the PHP file
by inserting declare(strict_types=1); immediately after the opening <?php tag in
the creators.php Symfony DI configuration file so the file follows the
repository coding guideline requiring strict typing for all PHP files.

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/event_handlers.php`:
- Around line 1-5: Add a strict types declaration and a return type to the
exported closure: insert declare(strict_types=1); immediately after the "<?php"
tag (before the namespace line) and change the closure signature from "return
static function(ContainerConfigurator $container) {" to "return static
function(ContainerConfigurator $container): void {" so the anonymous function
for ContainerConfigurator has an explicit void return type.

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/providers.php`:
- Around line 1-3: Add a strict types declaration to the top of the file by
inserting declare(strict_types=1); as the very first statement (before the
namespace line). Ensure it's placed above "namespace
Symfony\Component\DependencyInjection\Loader\Configurator;" so the file conforms
to the coding guideline requiring strict types.

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/resolvers.php`:
- Around line 1-3: Add the strict types declaration to the top of the PHP file
so it begins with declare(strict_types=1); immediately after the opening <?php
and before the namespace declaration for
Symfony\Component\DependencyInjection\Loader\Configurator; ensure there are no
blank lines or other tokens before the declare statement.

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/section_resolver.php`:
- Around line 8-16: The service definitions for
sylius_api.section_resolver.admin_api_uri_based and
sylius_api.section_resolver.shop_api_uri_based use string class names; replace
them with class constants (AdminApiUriBasedSectionResolver::class and
ShopApiUriBasedSectionResolver::class) and add corresponding use statements for
Sylius\Bundle\ApiBundle\SectionResolver\AdminApiUriBasedSectionResolver and
Sylius\Bundle\ApiBundle\SectionResolver\ShopApiUriBasedSectionResolver at the
top of the file so the $services->set(...) calls use the ::class constants
instead of hard-coded strings and keep the existing ->args(...) and ->tag(...)
calls unchanged.

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/security.php`:
- Around line 1-3: Add the missing strict types declaration by inserting
declare(strict_types=1); immediately after the opening <?php tag and before the
namespace declaration so the file begins with the strict types directive; ensure
no other output or code precedes it and keep the existing namespace
Symfony\Component\DependencyInjection\Loader\Configurator; intact.

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/serializers.php`:
- Around line 30-38: The route arrays passed into the service definition for
sylius_api.normalizer.product (ProductNormalizer) use duplicate '' keys which
cause earlier entries to be overwritten; update both route argument arrays (the
two arrays currently written as ['' => 'sylius:shop:product:index', '' =>
'sylius:shop:product:show'] and ['' =>
'sylius:shop:product:index:default_variant', '' =>
'sylius:shop:product:show:default_variant']) to use indexed arrays (e.g.
['sylius:shop:product:index', 'sylius:shop:product:show']) so they preserve all
values, and apply the same indexed-array fix to the equivalent arrays referenced
later around the other serializer/service definitions mentioned in the comment.

In
`@src/Sylius/Bundle/ApiBundle/Resources/config/services/shop/state_providers.php`:
- Around line 1-2: This PHP file is missing the strict types declaration: add
declare(strict_types=1); immediately after the opening <?php tag so the file
begins with <?php followed by declare(strict_types=1); to enforce strict typing
per coding guidelines.

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/state_processors.php`:
- Around line 1-2: This PHP file is missing the strict types declaration; add
declare(strict_types=1); immediately after the opening <?php tag in
src/Sylius/Bundle/ApiBundle/Resources/config/services/state_processors.php so
the file begins with the strict types declaration per project coding guidelines.
🧹 Nitpick comments (19)
src/Sylius/Bundle/ApiBundle/Resources/config/services/controllers.php (1)

1-5: Add declare(strict_types=1); and return type to the closure.

The file is missing the strict types declaration required by the coding guidelines. Additionally, the closure should have a void return type for completeness.

♻️ Proposed fix
 <?php
 
+declare(strict_types=1);
+
 namespace Symfony\Component\DependencyInjection\Loader\Configurator;
 
-return static function(ContainerConfigurator $container) {
+return static function (ContainerConfigurator $container): void {
     $services = $container->services();

As per coding guidelines: "Declare strict_types=1 at the beginning of all PHP files" and "Add type declarations for all properties, arguments, and return values in PHP code".

src/Sylius/Bundle/ApiBundle/Resources/config/services/security.php (1)

13-15: Redundant security.voter tag on order_adjustments voter.

The ->tag('security.voter') on Line 15 is redundant since defaults() on Lines 8-9 already applies this tag to all services in this file.

Proposed fix
     $services->set('sylius_api.security.voter.order_adjustments', 'Sylius\Bundle\ApiBundle\Security\OrderAdjustmentsVoter')
-        ->args([service('sylius_api.provider.adjustment_order')])
-        ->tag('security.voter');
+        ->args([service('sylius_api.provider.adjustment_order')]);
 };
src/Sylius/Bundle/ApiBundle/Resources/config/services/resolvers.php (1)

8-14: Consider using ::class constants instead of string class names.

Using ::class constants improves IDE support, enables better static analysis, and makes refactoring safer.

Proposed refactor
+use Sylius\Bundle\ApiBundle\Resolver\OperationResolverInterface;
+use Sylius\Bundle\ApiBundle\Resolver\PathPrefixBasedOperationResolver;
+use Sylius\Bundle\ApiBundle\Resolver\UriTemplateParentResourceResolver;
+
 return static function (ContainerConfigurator $container) {
     $services = $container->services();
 
-    $services->set('sylius_api.operation_resolver.path_prefix_based', 'Sylius\Bundle\ApiBundle\Resolver\PathPrefixBasedOperationResolver')
+    $services->set('sylius_api.operation_resolver.path_prefix_based', PathPrefixBasedOperationResolver::class)
         ->args([service('api_platform.metadata.resource.metadata_collection_factory')]);
 
-    $services->alias('Sylius\Bundle\ApiBundle\Resolver\OperationResolverInterface', 'sylius_api.operation_resolver.path_prefix_based');
+    $services->alias(OperationResolverInterface::class, 'sylius_api.operation_resolver.path_prefix_based');
 
-    $services->set('sylius_api.resolver.uri_template_parent_resource_resolver', 'Sylius\Bundle\ApiBundle\Resolver\UriTemplateParentResourceResolver')
+    $services->set('sylius_api.resolver.uri_template_parent_resource_resolver', UriTemplateParentResourceResolver::class)
         ->args([service('doctrine.orm.entity_manager')]);
 };
src/Sylius/Bundle/ApiBundle/Resources/config/services/command_handlers.php (1)

8-17: Consider using ::class constants instead of string literals for handler classes.

Using ::class constants provides better IDE support (autocompletion, refactoring), catches typos at compile time, and makes it easier to track usages. This applies to all handler class definitions in this file.

Example refactor for the first handler
+use Sylius\Bundle\ApiBundle\CommandHandler\Account\RegisterShopUserHandler;
+
 return static function (ContainerConfigurator $container) {
     $services = $container->services();
 
-    $services->set('sylius_api.command_handler.account.register_shop_user', 'Sylius\Bundle\ApiBundle\CommandHandler\Account\RegisterShopUserHandler')
+    $services->set('sylius_api.command_handler.account.register_shop_user', RegisterShopUserHandler::class)
src/Sylius/Bundle/ApiBundle/Resources/config/services/api_payment_methods.php (2)

1-6: Add strict_types and an explicit void return type.

This keeps the config file aligned with the PHP type-safety rules used elsewhere.

Proposed change
 <?php

+declare(strict_types=1);
+
 namespace Symfony\Component\DependencyInjection\Loader\Configurator;

-return static function(ContainerConfigurator $container) {
+return static function(ContainerConfigurator $container): void {
As per coding guidelines: Declare `strict_types=1` at the beginning of all PHP files; Add type declarations for all properties, arguments, and return values in PHP code.

3-13: Prefer ::class constants with imports for service wiring.

Using class constants improves refactor safety and matches the required import usage.

Proposed change
 namespace Symfony\Component\DependencyInjection\Loader\Configurator;

+use Sylius\Bundle\ApiBundle\Provider\CompositePaymentConfigurationProvider;
+use Sylius\Bundle\ApiBundle\Provider\CompositePaymentConfigurationProviderInterface;

-$services->set('sylius_api.provider.payment_configuration', 'Sylius\Bundle\ApiBundle\Provider\CompositePaymentConfigurationProvider')
+$services->set('sylius_api.provider.payment_configuration', CompositePaymentConfigurationProvider::class)
     ->args([tagged_iterator('sylius.api.payment_method_handler')]);

-    $services->alias('Sylius\Bundle\ApiBundle\Provider\CompositePaymentConfigurationProviderInterface', 'sylius_api.provider.payment_configuration');
+    $services->alias(CompositePaymentConfigurationProviderInterface::class, 'sylius_api.provider.payment_configuration');
As per coding guidelines: Use `use` statements for all non-global classes in PHP.
src/Sylius/Bundle/ApiBundle/Resources/config/services/payments.php (2)

1-6: Add strict_types and an explicit void return type.

This keeps the config file aligned with the PHP type-safety rules used elsewhere.

Proposed change
 <?php

+declare(strict_types=1);
+
 namespace Symfony\Component\DependencyInjection\Loader\Configurator;

-return static function(ContainerConfigurator $container) {
+return static function(ContainerConfigurator $container): void {
As per coding guidelines: Declare `strict_types=1` at the beginning of all PHP files; Add type declarations for all properties, arguments, and return values in PHP code.

3-15: Prefer ::class constants with imports for service wiring.

Using class constants improves refactor safety and matches the required import usage.

Proposed change
 namespace Symfony\Component\DependencyInjection\Loader\Configurator;

+use Sylius\Bundle\ApiBundle\Controller\Payment\GetPaymentConfiguration;

-$services->set('sylius_api.controller.payment.get_payment_configuration', 'Sylius\Bundle\ApiBundle\Controller\Payment\GetPaymentConfiguration')
+$services->set('sylius_api.controller.payment.get_payment_configuration', GetPaymentConfiguration::class)
     ->args([
         service('sylius.repository.payment'),
         service('sylius_api.provider.payment_configuration'),
     ]);
As per coding guidelines: Use `use` statements for all non-global classes in PHP.
src/Sylius/Bundle/ApiBundle/Resources/config/services/event_subscribers.php (1)

1-6: Add strict_types and a void return type to the configurator closure.

This file should declare strict types and the closure should declare its return type.

♻️ Suggested update
 <?php
+
+declare(strict_types=1);

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

As per coding guidelines: Declare strict_types=1 at the beginning of all PHP files; Add type declarations for all properties, arguments, and return values in PHP code.

src/Sylius/Bundle/ApiBundle/Resources/config/integrations/swagger.php (1)

1-6: Add strict_types and a void return type to the configurator closure.

This file should declare strict types and the closure should declare its return type.

♻️ Suggested update
 <?php
+
+declare(strict_types=1);

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

As per coding guidelines: Declare strict_types=1 at the beginning of all PHP files; Add type declarations for all properties, arguments, and return values in PHP code.

src/Sylius/Bundle/ApiBundle/Resources/config/services/query_handlers.php (1)

1-6: Add strict_types and a void return type to the configurator closure.

This file should declare strict types and the closure should declare its return type.

♻️ Suggested update
 <?php
+
+declare(strict_types=1);

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

As per coding guidelines: Declare strict_types=1 at the beginning of all PHP files; Add type declarations for all properties, arguments, and return values in PHP code.

src/Sylius/Bundle/ApiBundle/Resources/config/services.php (1)

1-8: Add strict_types and a void return type to the configurator closure.

This file should declare strict types and the closure should declare its return type.

♻️ Suggested update
 <?php
+
+declare(strict_types=1);

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

As per coding guidelines: Declare strict_types=1 at the beginning of all PHP files; Add type declarations for all properties, arguments, and return values in PHP code.

src/Sylius/Bundle/ApiBundle/Resources/config/services/api_platform.php (1)

1-8: Add strict_types and a void return type to the configurator closure.

This file should declare strict types and the closure should declare its return type.

♻️ Suggested update
 <?php
+
+declare(strict_types=1);

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

As per coding guidelines: Declare strict_types=1 at the beginning of all PHP files; Add type declarations for all properties, arguments, and return values in PHP code.

src/Sylius/Bundle/ApiBundle/Resources/config/services/serializers.php (1)

1-8: Add strict_types and a void return type to the configurator closure.

This file should declare strict types and the closure should declare its return type.

♻️ Suggested update
 <?php
+
+declare(strict_types=1);

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

As per coding guidelines: Declare strict_types=1 at the beginning of all PHP files; Add type declarations for all properties, arguments, and return values in PHP code.

src/Sylius/Bundle/ApiBundle/Resources/config/services/extensions.php (1)

1-2: Missing declare(strict_types=1) declaration.

Per coding guidelines, all PHP files should declare strict types at the beginning.

Proposed fix
 <?php
+
+declare(strict_types=1);
 
 namespace Symfony\Component\DependencyInjection\Loader\Configurator;
src/Sylius/Bundle/ApiBundle/Resources/config/services/context_builders.php (1)

1-2: Missing declare(strict_types=1) declaration.

Per coding guidelines, all PHP files should declare strict types at the beginning.

Proposed fix
 <?php
+
+declare(strict_types=1);
 
 namespace Symfony\Component\DependencyInjection\Loader\Configurator;
src/Sylius/Bundle/ApiBundle/Resources/config/services/validator.php (1)

1-2: Missing declare(strict_types=1) declaration.

Per coding guidelines, all PHP files should declare strict types at the beginning.

Proposed fix
 <?php
+
+declare(strict_types=1);
 
 namespace Symfony\Component\DependencyInjection\Loader\Configurator;
src/Sylius/Bundle/ApiBundle/Resources/config/services/admin/filters.php (1)

1-2: Missing declare(strict_types=1) declaration.

Per coding guidelines, all PHP files should declare strict types at the beginning.

Proposed fix
 <?php
+
+declare(strict_types=1);
 
 namespace Symfony\Component\DependencyInjection\Loader\Configurator;
src/Sylius/Bundle/ApiBundle/Resources/config/services/shop/filters.php (1)

1-2: Missing declare(strict_types=1) declaration.

Per coding guidelines, all PHP files should declare strict types at the beginning.

Proposed fix
 <?php
+
+declare(strict_types=1);
 
 namespace Symfony\Component\DependencyInjection\Loader\Configurator;

Comment on lines +1 to +5
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

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

🧩 Analysis chain

🏁 Script executed:

cat -n src/Sylius/Bundle/ApiBundle/Resources/config/services/applicators.php

Repository: Sylius/Sylius

Length of output: 2352


Add strict_types and a void return type for the configurator closure.

Both are required by the PHP guidelines and improve type safety.

🔧 Proposed fix
 <?php
+declare(strict_types=1);

 namespace Symfony\Component\DependencyInjection\Loader\Configurator;

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

As per coding guidelines, Declare strict_types=1 at the beginning of all PHP files; Add type declarations for all properties, arguments, and return values in PHP code.

📝 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
<?php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
return static function(ContainerConfigurator $container) {
<?php
declare(strict_types=1);
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
return static function (ContainerConfigurator $container): void {
🤖 Prompt for AI Agents
In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/applicators.php` around
lines 1 - 5, Add a file-level declare(strict_types=1); at the top and add a void
return type to the returned configurator closure; specifically, insert
declare(strict_types=1); after the opening <?php tag and change the returned
static function signature from static function(ContainerConfigurator $container)
to static function(ContainerConfigurator $container): void so the configurator
closure has an explicit void return type and the file uses strict types.

Comment on lines +1 to +2
<?php

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/ApiBundle/Resources/config/services/contexts.php | head -20

Repository: Sylius/Sylius

Length of output: 1006


🏁 Script executed:

wc -l src/Sylius/Bundle/ApiBundle/Resources/config/services/contexts.php

Repository: Sylius/Sylius

Length of output: 126


Add declare(strict_types=1); to the file header and declare return type for the closure.

The file is missing declare(strict_types=1); and the closure on line 5 lacks a return type declaration.

Suggested changes
 <?php
+declare(strict_types=1);
 
 namespace Symfony\Component\DependencyInjection\Loader\Configurator;
 
-return static function(ContainerConfigurator $container) {
+return static function(ContainerConfigurator $container): void {

Per coding guidelines, all PHP files must declare strict_types=1 at the start, and all functions and closures must include return type declarations.

🤖 Prompt for AI Agents
In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/contexts.php` around
lines 1 - 2, Add a strict types declaration at the top of the PHP file by
inserting declare(strict_types=1); after the opening <?php tag, and add an
explicit return type to the service configuration closure (the static function
accepting ContainerConfigurator $containerConfigurator) — e.g. append the
appropriate return type such as : void to that closure signature so the file
follows the project's strict typing and function return-type conventions.

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

🤖 Fix all issues with AI agents
In `@src/Sylius/Bundle/ApiBundle/Resources/config/services.php`:
- Around line 1-6: Add a strict types declaration and a void return type to the
service configurator closure: add a declare(strict_types=1) at the top of the
PHP file and change the anonymous configurator signature from static
function(ContainerConfigurator $container) to static
function(ContainerConfigurator $container): void so the closure explicitly
declares strict typing and a void return type (affecting the
ContainerConfigurator closure).

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/admin/filters.php`:
- Around line 1-3: Add a strict types declaration to the top of the PHP file by
inserting declare(strict_types=1); immediately after the opening <?php tag and
before the existing namespace statement (namespace
Symfony\Component\DependencyInjection\Loader\Configurator;), so the file
enforces strict typing per project guidelines.
- Around line 51-54: The exists_filter definition for the promotion admin
service uses a string instead of a boolean for the archivedAt argument; update
the service configuration for the promotion filter (service id like
sylius_api.exists_filter.admin.promotion) to use a boolean false for
['archivedAt'] (matching the shipping_method example that uses ['archivedAt' =>
false]) so the API Platform ExistsFilter receives a proper boolean value.

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/api_platform.php`:
- Around line 1-6: Add strict types and a void return type to the returned
configurator closure: insert declare(strict_types=1); immediately after the
opening <?php tag and change the closure signature returned by the file from
"static function(ContainerConfigurator $container)" to "static
function(ContainerConfigurator $container): void" so the file enforces strict
typing and the configurator has an explicit void return type; keep the existing
$services usage inside the closure unchanged.

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/command_handlers.php`:
- Around line 204-209: Rename the service ID to match the handler class: change
the service registration currently named
'sylius_api.command_handler.send_contract_request' to
'sylius_api.command_handler.send_contact_request' so it aligns with the
SendContactRequestHandler class; update any references to this service ID if
present elsewhere and ensure the args([...]) and
tag('messenger.message_handler', ['bus' => 'sylius.command_bus']) remain
unchanged.

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/context_builders.php`:
- Around line 1-3: Add the strict types declaration to the top of the file by
inserting declare(strict_types=1); as the very first statement before the
namespace declaration (namespace
Symfony\Component\DependencyInjection\Loader\Configurator;), ensuring the file
now begins with the strict types declaration followed by the existing namespace
line.

In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/validator.php`:
- Around line 1-3: This file is missing the strict types declaration; add
declare(strict_types=1); immediately after the opening <?php tag and before the
existing namespace import (the current namespace line "namespace
Symfony\Component\DependencyInjection\Loader\Configurator;") so the file
enforces strict typing per project guidelines.
🧹 Nitpick comments (5)
src/Sylius/Bundle/ApiBundle/Resources/config/services/event_handlers.php (1)

11-11: Consider using ::class constant instead of string class name.

Using OrderCompletedHandler::class provides better IDE support, enables refactoring tools, and catches typos at compile time.

Suggested fix
+use Sylius\Bundle\ApiBundle\EventHandler\OrderCompletedHandler;
+
 return static function (ContainerConfigurator $container): void {
     $services = $container->services();

     $services->defaults()
         ->public();

-    $services->set('sylius_api.event_handler.order_completed', 'Sylius\Bundle\ApiBundle\EventHandler\OrderCompletedHandler')
+    $services->set('sylius_api.event_handler.order_completed', OrderCompletedHandler::class)
         ->args([
src/Sylius/Bundle/ApiBundle/Resources/config/services/state_processors.php (1)

8-103: Add trailing commas to multi-line argument lists.

Per coding guidelines, multi-line arrays and argument lists should use trailing commas to facilitate cleaner diffs and easier additions.

Example fix for one service (apply pattern to all)
     $services->set('sylius_api.state_processor.admin.admin_user.remove', 'Sylius\Bundle\ApiBundle\StateProcessor\Admin\AdminUser\RemoveProcessor')
         ->args([
             service('api_platform.doctrine.orm.state.remove_processor'),
-            service('security.token_storage'),
+            service('security.token_storage'),
         ])
         ->tag('api_platform.state_processor');

Apply the same pattern to all ->args([...]) blocks, ensuring the last element has a trailing comma.

src/Sylius/Bundle/ApiBundle/Resources/config/services/admin/filters.php (1)

159-164: Add trailing comma in multi-line argument list.

Per coding guidelines, multi-line arrays and argument lists should use trailing commas for cleaner diffs and easier maintenance.

Proposed fix
     $services->set('sylius_api.catalog_promotion_search_filter.admin.product_variant', 'Sylius\Bundle\ApiBundle\Doctrine\ORM\Filter\ProductVariantCatalogPromotionFilter')
         ->args([
             service('api_platform.symfony.iri_converter'),
-            service('doctrine'),
+            service('doctrine'),
         ])
         ->tag('api_platform.filter');

Note: The same applies to the ChannelsAwareChannelFilter definition at lines 186-191.

src/Sylius/Bundle/ApiBundle/Resources/config/services/admin/state_providers.php (2)

5-6: Add an explicit : void return type to the configurator closure.

This closure doesn't return a value, so declare it explicitly.
As per coding guidelines: "Add type declarations for all properties, arguments, and return values in PHP code".

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

8-20: Prefer ::class with a use import instead of string class names.

This is more refactor-safe and aligns with the import guideline.
As per coding guidelines: "Use use statements for all non-global classes in PHP".

✅ Proposed fix
 namespace Symfony\Component\DependencyInjection\Loader\Configurator;
 
+use Sylius\Bundle\ApiBundle\StateProvider\Common\Adjustment\CollectionProvider;
+
 return static function (ContainerConfigurator $container): void {
     $services = $container->services();
 
-    $services->set('sylius_api.state_provider.admin.order.adjustment.collection', 'Sylius\Bundle\ApiBundle\StateProvider\Common\Adjustment\CollectionProvider')
+    $services->set('sylius_api.state_provider.admin.order.adjustment.collection', CollectionProvider::class)
         ->args([
             service('sylius.repository.order'),
             'tokenValue',
         ])
         ->tag('api_platform.state_provider', ['priority' => 10]);
 
-    $services->set('sylius_api.state_provider.admin.order_item.adjustment.collection', 'Sylius\Bundle\ApiBundle\StateProvider\Common\Adjustment\CollectionProvider')
+    $services->set('sylius_api.state_provider.admin.order_item.adjustment.collection', CollectionProvider::class)
         ->args([
             service('sylius.repository.order_item'),
             'id',
         ])
         ->tag('api_platform.state_provider', ['priority' => 10]);
 };

Comment on lines +1 to +6
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

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

Add strict types and a void return type to the configurator closure.

Proposed fix
 <?php
+
+declare(strict_types=1);
+
 namespace Symfony\Component\DependencyInjection\Loader\Configurator;
 
-return static function(ContainerConfigurator $container) {
+return static function(ContainerConfigurator $container): void {
As per coding guidelines: Declare `strict_types=1` at the beginning of all PHP files; Add type declarations for all properties, arguments, and return values in PHP code.
🤖 Prompt for AI Agents
In `@src/Sylius/Bundle/ApiBundle/Resources/config/services.php` around lines 1 -
6, Add a strict types declaration and a void return type to the service
configurator closure: add a declare(strict_types=1) at the top of the PHP file
and change the anonymous configurator signature from static
function(ContainerConfigurator $container) to static
function(ContainerConfigurator $container): void so the closure explicitly
declares strict typing and a void return type (affecting the
ContainerConfigurator closure).

Comment on lines +51 to +54
$services->set('sylius_api.exists_filter.admin.shipping_method')
->parent('api_platform.doctrine.orm.exists_filter')
->args([['archivedAt' => false]])
->tag('api_platform.filter');
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:

# Search for the specific file and examine lines 51-54 and 238-241
cat -n src/Sylius/Bundle/ApiBundle/Resources/config/services/admin/filters.php | sed -n '45,60p'

Repository: Sylius/Sylius

Length of output: 837


🏁 Script executed:

# Also check lines 238-241
cat -n src/Sylius/Bundle/ApiBundle/Resources/config/services/admin/filters.php | sed -n '235,245p'

Repository: Sylius/Sylius

Length of output: 612


🏁 Script executed:

# Search for all exists_filter configurations to understand the pattern
rg -n 'exists_filter' --type php -B 2 -A 2 src/Sylius/Bundle/ApiBundle/Resources/config/services/admin/filters.php

Repository: Sylius/Sylius

Length of output: 588


🏁 Script executed:

# Search for all exists_filter configurations to see if there's a pattern
rg -n 'exists_filter' --type php -B 1 -A 3 src/Sylius/Bundle/ApiBundle/Resources/config/services/

Repository: Sylius/Sylius

Length of output: 1378


🏁 Script executed:

# Count how many times each pattern appears
rg -n "archivedAt.*=>" --type php src/Sylius/Bundle/ApiBundle/Resources/config/services/ | wc -l

Repository: Sylius/Sylius

Length of output: 58


🏁 Script executed:

# Check all archivedAt filter configurations in the file
rg -n "'archivedAt'" --type php src/Sylius/Bundle/ApiBundle/Resources/config/services/admin/filters.php

Repository: Sylius/Sylius

Length of output: 144


🏁 Script executed:

# Check if there are other exists_filter configurations in shop filters (if they exist)
find src/Sylius/Bundle/ApiBundle/Resources/config/services -name "*.php" -type f | head -20

Repository: Sylius/Sylius

Length of output: 1487


🏁 Script executed:

# Look for any documentation or comments about exists_filter behavior
rg -n 'exists_filter|ExistsFilter' --type php -B 5 -A 5 src/Sylius/Bundle/ApiBundle/ | head -50

Repository: Sylius/Sylius

Length of output: 2999


🏁 Script executed:

# Check if there's a pattern in other filter value types to understand the convention
rg -n "'archivedAt'" --type php -B 1 -A 1 src/Sylius/Bundle/ApiBundle/

Repository: Sylius/Sylius

Length of output: 1584


🏁 Script executed:

# Check the API Platform exists_filter documentation or implementation details
rg -n 'exists' --type php src/Sylius/Bundle/ApiBundle/Doctrine/ORM/QueryExtension/Common/NonArchivedExtension.php -B 5 -A 5

Repository: Sylius/Sylius

Length of output: 360


🏁 Script executed:

# Look for test cases that use exists_filter to understand expected behavior
find src/Sylius/Bundle/ApiBundle -name "*test*" -o -name "*Test*" | xargs grep -l 'exists_filter\|ExistsFilter' 2>/dev/null | head -5

Repository: Sylius/Sylius

Length of output: 39


🏁 Script executed:

# Check if there's a pattern with other exists_filter uses in the broader codebase
rg -n 'exists.*Filter' --type php src/Sylius/ | grep -v test | head -20

Repository: Sylius/Sylius

Length of output: 39


Incorrect value type in exists_filter for archivedAt on line 240.

The exists_filter for the promotion resource uses an empty string '' instead of a boolean. API Platform's ExistsFilter expects boolean values:

  • Line 53 (shipping_method): ['archivedAt' => false] ✓ correct
  • Line 240 (promotion): ['archivedAt' => ''] ✗ should be false

Change line 240 to match the proper boolean type used in line 53.

🤖 Prompt for AI Agents
In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/admin/filters.php`
around lines 51 - 54, The exists_filter definition for the promotion admin
service uses a string instead of a boolean for the archivedAt argument; update
the service configuration for the promotion filter (service id like
sylius_api.exists_filter.admin.promotion) to use a boolean false for
['archivedAt'] (matching the shipping_method example that uses ['archivedAt' =>
false]) so the API Platform ExistsFilter receives a proper boolean value.

Comment on lines +1 to +6
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

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

Add strict types and a void return type to the configurator closure.

Proposed fix
 <?php
+
+declare(strict_types=1);
+
 namespace Symfony\Component\DependencyInjection\Loader\Configurator;
 
-return static function(ContainerConfigurator $container) {
+return static function(ContainerConfigurator $container): void {
As per coding guidelines: Declare `strict_types=1` at the beginning of all PHP files; Add type declarations for all properties, arguments, and return values in PHP code.
📝 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
<?php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
return static function(ContainerConfigurator $container) {
$services = $container->services();
<?php
declare(strict_types=1);
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
return static function(ContainerConfigurator $container): void {
$services = $container->services();
🤖 Prompt for AI Agents
In `@src/Sylius/Bundle/ApiBundle/Resources/config/services/api_platform.php`
around lines 1 - 6, Add strict types and a void return type to the returned
configurator closure: insert declare(strict_types=1); immediately after the
opening <?php tag and change the closure signature returned by the file from
"static function(ContainerConfigurator $container)" to "static
function(ContainerConfigurator $container): void" so the file enforces strict
typing and the configurator has an explicit void return type; keep the existing
$services usage inside the closure unchanged.

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

🤖 Fix all issues with AI agents
In
`@src/Sylius/Bundle/ApiBundle/Resources/config/services/shop/state_providers.php`:
- Around line 61-76: The two state provider service definitions for
ShippingMethodCollectionProvider (service id
'sylius_api.state_provider.shop.order.shipment.shipping_method.collection',
class ShippingMethodCollectionProvider::class) and
PaymentMethodCollectionProvider (service id
'sylius_api.state_provider.shop.order.payment.payment_method.collection', class
PaymentMethodCollectionProvider::class) are missing the priority attribute on
their api_platform.state_provider tags; update each
->tag('api_platform.state_provider') call to
->tag('api_platform.state_provider', ['priority' => 10]) so they match the other
providers' priority.
🧹 Nitpick comments (2)
src/Sylius/Bundle/ApiBundle/Resources/config/services/serializers.php (1)

95-126: Minor inconsistency: service(RequestStack::class) vs service('request_stack').

Line 98 uses the string service ID service('request_stack') for the ImageNormalizer, while line 123 uses the FQCN service(RequestStack::class) for the ShippingMethodNormalizer. Both resolve to the same service, but mixing styles reduces readability. Consider standardizing on one form.

Proposed fix (use string ID consistently)
     $services->set('sylius_api.normalizer.shipping_method', ShippingMethodNormalizer::class)
         ->args([
             service('sylius.section_resolver.uri_based'),
             service('sylius.repository.order'),
             service('sylius.repository.shipment'),
             service('sylius.registry.shipping_calculator'),
-            service(RequestStack::class),
+            service('request_stack'),
             ['sylius:shop:shipping_method:index'],
         ])
         ->tag('serializer.normalizer', ['priority' => 64]);
src/Sylius/Bundle/ApiBundle/Resources/config/services/state_processors.php (1)

31-31: Add : void return type to the closure, and consider applying this fix systematically across all sibling service configuration files.

The closure at line 31 lacks a return type declaration. This pattern is consistent across all 23 service configuration files in src/Sylius/Bundle/ApiBundle/Resources/config/services/ (e.g., validators.php, serializers.php, security.php, and others), which should ideally be updated together for consistency per the coding guideline: "Add type declarations for all properties, arguments, and return values in PHP code".

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

Comment on lines +61 to +76
$services->set('sylius_api.state_provider.shop.order.shipment.shipping_method.collection', ShippingMethodCollectionProvider::class)
->args([
service('sylius.section_resolver.uri_based'),
service('sylius.repository.shipment'),
service('sylius.resolver.shipping_methods'),
])
->tag('api_platform.state_provider');

$services->set('sylius_api.state_provider.shop.order.payment.payment_method.collection', PaymentMethodCollectionProvider::class)
->args([
service('sylius.repository.payment'),
service('sylius.repository.order'),
service('sylius.section_resolver.uri_based'),
service('sylius.resolver.payment_methods'),
])
->tag('api_platform.state_provider');
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:

fd 'state_providers.xml' src/Sylius/Bundle/ApiBundle/Resources/config/services/shop/ --exec cat {}

Repository: Sylius/Sylius

Length of output: 39


🏁 Script executed:

#!/bin/bash
# Search for all state_providers configuration files
fd 'state_providers' src/Sylius/Bundle/ApiBundle/Resources/config/services/

# Also check the full PHP file to see priority pattern
echo "=== Full PHP file for priority pattern ==="
cat -n src/Sylius/Bundle/ApiBundle/Resources/config/services/shop/state_providers.php

Repository: Sylius/Sylius

Length of output: 6885


🏁 Script executed:

# Also check admin state_providers for comparison
cat -n src/Sylius/Bundle/ApiBundle/Resources/config/services/admin/state_providers.php | head -100

Repository: Sylius/Sylius

Length of output: 1349


Add ['priority' => 10] to both ShippingMethodCollectionProvider and PaymentMethodCollectionProvider state provider tags.

Lines 67 and 76 are missing the priority tag that all other state providers in this file (and the admin state_providers.php) specify. Add ['priority' => 10] to both tags to maintain consistency.

        ->tag('api_platform.state_provider', ['priority' => 10]);
🤖 Prompt for AI Agents
In
`@src/Sylius/Bundle/ApiBundle/Resources/config/services/shop/state_providers.php`
around lines 61 - 76, The two state provider service definitions for
ShippingMethodCollectionProvider (service id
'sylius_api.state_provider.shop.order.shipment.shipping_method.collection',
class ShippingMethodCollectionProvider::class) and
PaymentMethodCollectionProvider (service id
'sylius_api.state_provider.shop.order.payment.payment_method.collection', class
PaymentMethodCollectionProvider::class) are missing the priority attribute on
their api_platform.state_provider tags; update each
->tag('api_platform.state_provider') call to
->tag('api_platform.state_provider', ['priority' => 10]) so they match the other
providers' priority.

@TheMilek TheMilek merged commit 665a4f7 into Sylius:2.3 Feb 6, 2026
36 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Feb 6, 2026
@loic425 loic425 deleted the xml2php/api branch February 25, 2026 13:08
@coderabbitai coderabbitai bot mentioned this pull request Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API APIs related issues and PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants