Conversation
📝 WalkthroughWalkthroughReplaces 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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
❌ Preview Environment deleted from BunnyshellAvailable commands:
|
There was a problem hiding this comment.
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: Adddeclare(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
voidreturn 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=1at 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: Redundantsecurity.votertag onorder_adjustmentsvoter.The
->tag('security.voter')on Line 15 is redundant sincedefaults()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::classconstants instead of string class names.Using
::classconstants 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::classconstants instead of string literals for handler classes.Using
::classconstants 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: Addstrict_typesand an explicitvoidreturn type.This keeps the config file aligned with the PHP type-safety rules used elsewhere.
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.Proposed change
<?php +declare(strict_types=1); + namespace Symfony\Component\DependencyInjection\Loader\Configurator; -return static function(ContainerConfigurator $container) { +return static function(ContainerConfigurator $container): void {
3-13: Prefer::classconstants with imports for service wiring.Using class constants improves refactor safety and matches the required import usage.
As per coding guidelines: Use `use` statements for all non-global classes in PHP.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');src/Sylius/Bundle/ApiBundle/Resources/config/services/payments.php (2)
1-6: Addstrict_typesand an explicitvoidreturn type.This keeps the config file aligned with the PHP type-safety rules used elsewhere.
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.Proposed change
<?php +declare(strict_types=1); + namespace Symfony\Component\DependencyInjection\Loader\Configurator; -return static function(ContainerConfigurator $container) { +return static function(ContainerConfigurator $container): void {
3-15: Prefer::classconstants with imports for service wiring.Using class constants improves refactor safety and matches the required import usage.
As per coding guidelines: Use `use` statements for all non-global classes in PHP.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'), ]);src/Sylius/Bundle/ApiBundle/Resources/config/services/event_subscribers.php (1)
1-6: Addstrict_typesand avoidreturn 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=1at 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: Addstrict_typesand avoidreturn 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=1at 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: Addstrict_typesand avoidreturn 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=1at 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: Addstrict_typesand avoidreturn 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=1at 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: Addstrict_typesand avoidreturn 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=1at 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: Addstrict_typesand avoidreturn 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=1at 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: Missingdeclare(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: Missingdeclare(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: Missingdeclare(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: Missingdeclare(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: Missingdeclare(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/state_providers.php
Show resolved
Hide resolved
| <?php | ||
|
|
||
| namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
|
||
| return static function(ContainerConfigurator $container) { |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n src/Sylius/Bundle/ApiBundle/Resources/config/services/applicators.phpRepository: 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.
| <?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.
src/Sylius/Bundle/ApiBundle/Resources/config/services/applicators.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Resources/config/services/command_handlers.php
Outdated
Show resolved
Hide resolved
| <?php | ||
|
|
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n src/Sylius/Bundle/ApiBundle/Resources/config/services/contexts.php | head -20Repository: Sylius/Sylius
Length of output: 1006
🏁 Script executed:
wc -l src/Sylius/Bundle/ApiBundle/Resources/config/services/contexts.phpRepository: 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.
src/Sylius/Bundle/ApiBundle/Resources/config/services/section_resolver.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Resources/config/services/serializers.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Resources/config/services/shop/state_providers.php
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Resources/config/services/state_processors.php
Show resolved
Hide resolved
There was a problem hiding this comment.
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::classconstant instead of string class name.Using
OrderCompletedHandler::classprovides 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
ChannelsAwareChannelFilterdefinition at lines 186-191.src/Sylius/Bundle/ApiBundle/Resources/config/services/admin/state_providers.php (2)
5-6: Add an explicit: voidreturn 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::classwith auseimport instead of string class names.This is more refactor-safe and aligns with the import guideline.
As per coding guidelines: "Useusestatements 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]); };
| <?php | ||
|
|
||
| namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
|
||
| return static function(ContainerConfigurator $container) { | ||
| $services = $container->services(); |
There was a problem hiding this comment.
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 {🤖 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).
| $services->set('sylius_api.exists_filter.admin.shipping_method') | ||
| ->parent('api_platform.doctrine.orm.exists_filter') | ||
| ->args([['archivedAt' => false]]) | ||
| ->tag('api_platform.filter'); |
There was a problem hiding this comment.
🧩 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.phpRepository: 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 -lRepository: 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.phpRepository: 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 -20Repository: 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 -50Repository: 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 5Repository: 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 -5Repository: 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 -20Repository: 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 befalse
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.
| <?php | ||
|
|
||
| namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
|
||
| return static function(ContainerConfigurator $container) { | ||
| $services = $container->services(); |
There was a problem hiding this comment.
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 {📝 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.
| <?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.
src/Sylius/Bundle/ApiBundle/Resources/config/services/command_handlers.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Resources/config/services/context_builders.php
Show resolved
Hide resolved
There was a problem hiding this comment.
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)vsservice('request_stack').Line 98 uses the string service ID
service('request_stack')for theImageNormalizer, while line 123 uses the FQCNservice(RequestStack::class)for theShippingMethodNormalizer. 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: voidreturn 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 {
| $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'); |
There was a problem hiding this comment.
🧩 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.phpRepository: 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 -100Repository: 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.
Summary by CodeRabbit