Conversation
📝 WalkthroughWalkthroughReplaces XML DI configs with PHP equivalents in the Sylius AttributeBundle, switching the bundle Extension to use PhpFileLoader and new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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:
|
eb04bd6 to
f80ad23
Compare
f80ad23 to
6e02f34
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In `@composer-require-checker.json`:
- Line 5: The whitelist contains the incorrect casing "Datetime" which is
case-sensitive and must be "DateTime"; open composer-require-checker.json,
locate the array entry "Datetime" and replace it with "DateTime" so the built-in
PHP class is correctly whitelisted and prevents false positives.
In `@src/Sylius/Bundle/AttributeBundle/Resources/config/services.php`:
- Around line 1-3: This file is missing the required PHP strict types
declaration; update
src/Sylius/Bundle/AttributeBundle/Resources/config/services.php by inserting
declare(strict_types=1); immediately after the opening <?php tag (before the
namespace Symfony\Component\DependencyInjection\Loader\Configurator; line) to
comply with the coding guidelines.
In
`@src/Sylius/Bundle/AttributeBundle/Resources/config/services/attribute_types.php`:
- Around line 26-27: The tag metadata uses the incorrect canonical casing for
the PHP DateTime class: change the tag entry 'label' value from \Datetime to
\DateTime in the service definition for sylius.attribute_type.datetime (class
Sylius\Component\Attribute\AttributeType\DatetimeAttributeType) so the tag array
['attribute_type' => 'datetime', 'label' => \Datetime, 'form_type' =>
'Sylius\Bundle\AttributeBundle\Form\Type\AttributeType\DatetimeAttributeType',
'configuration_form_type' =>
'Sylius\Bundle\AttributeBundle\Form\Type\AttributeType\Configuration\DatetimeAttributeConfigurationType']
uses \DateTime for consistent IDE/runtime recognition.
- Around line 1-3: Add the PHP strict types declaration at the top of the file
by inserting declare(strict_types=1); immediately after the opening <?php tag
and before the namespace line so the file (attribute_types.php) enforces strict
typing as required by the coding guidelines.
🧹 Nitpick comments (4)
src/Sylius/Bundle/AttributeBundle/Resources/config/services.php (2)
5-5: Add space betweenfunctionkeyword and parenthesis.PSR-12 requires a space before the opening parenthesis in closure declarations.
Proposed fix
-return static function(ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void {
10-10: Consider using::classconstant for better IDE support.Using the class constant provides autocompletion, refactoring support, and compile-time validation.
Example
- $parameters->set('sylius.model.attribute.interface', 'Sylius\Component\Attribute\AttributeType\AttributeTypeInterface'); + $parameters->set('sylius.model.attribute.interface', \Sylius\Component\Attribute\AttributeType\AttributeTypeInterface::class);This applies to all string class references throughout the file.
src/Sylius/Bundle/AttributeBundle/Resources/config/services/attribute_types.php (2)
5-5: Add space betweenfunctionkeyword and parenthesis.PSR-12 requires a space before the opening parenthesis in closure declarations.
Proposed fix
-return static function(ContainerConfigurator $container) { +return static function (ContainerConfigurator $container): void {
8-33: Consider splitting long tag definitions across multiple lines for readability.The tag definitions with multiple attributes are quite long. Splitting them improves readability and makes diffs cleaner.
Example for one service
$services->set('sylius.attribute_type.text', 'Sylius\Component\Attribute\AttributeType\TextAttributeType') - ->tag('sylius.attribute.type', ['attribute_type' => 'text', 'label' => 'Text', 'form_type' => 'Sylius\Bundle\AttributeBundle\Form\Type\AttributeType\TextAttributeType', 'configuration_form_type' => 'Sylius\Bundle\AttributeBundle\Form\Type\AttributeType\Configuration\TextAttributeConfigurationType']); + ->tag('sylius.attribute.type', [ + 'attribute_type' => 'text', + 'label' => 'Text', + 'form_type' => 'Sylius\Bundle\AttributeBundle\Form\Type\AttributeType\TextAttributeType', + 'configuration_form_type' => 'Sylius\Bundle\AttributeBundle\Form\Type\AttributeType\Configuration\TextAttributeConfigurationType', + ]) + ;
Summary by CodeRabbit
Refactor
Chores