Skip to content

[XML2PHP] Attribute#18495

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

[XML2PHP] Attribute#18495
TheMilek merged 2 commits intoSylius:2.3from
loic425:xml2php/attribute

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

  • Refactor

    • Migrated AttributeBundle service configuration from XML to PHP; attribute type and related form/validator services are now defined in PHP-based DI files.
  • Chores

    • Reordered two public whitelist entries so "inline_service" now precedes "service".

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Oct 31, 2025

📝 Walkthrough

Walkthrough

Replaces XML DI configs with PHP equivalents in the Sylius AttributeBundle, switching the bundle Extension to use PhpFileLoader and new services.php files; removes the old XML service files and adds PHP service definitions. Also a minor reorder in composer-require-checker.json whitelist entries.

Changes

Cohort / File(s) Summary
Composer whitelist
composer-require-checker.json
Swapped order of two public whitelist entries (service, inline_service) — only reordering, no symbol additions or removals in this diff.
Bundle Extension
src/Sylius/Bundle/AttributeBundle/DependencyInjection/SyliusAttributeExtension.php
Replaced XmlFileLoader import/usage with PhpFileLoader and changed loaded file from services.xml to services.php.
Main services config (XML → PHP)
src/Sylius/Bundle/AttributeBundle/Resources/config/services.php, src/Sylius/Bundle/AttributeBundle/Resources/config/services.xml
Added PHP-based service definitions (services.php) and removed the prior XML file; defines event subscriber, registries, form types, and validators in PHP.
Attribute types config (XML → PHP)
src/Sylius/Bundle/AttributeBundle/Resources/config/services/attribute_types.php, src/Sylius/Bundle/AttributeBundle/Resources/config/services/attribute_types.xml
Added PHP attribute type service registrations (text, textarea, checkbox, integer, float, percent, datetime, date, select) and related form-type services; removed corresponding XML file.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰
I hopped through XML leaves today,
Swapped them for PHP where services play,
Registries, forms, subscribers in tow,
Cleaner nests where definitions grow,
A little hop, and onward I go.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[XML2PHP] Attribute' clearly indicates the main change—converting XML-based service configurations to PHP-based configurations in the AttributeBundle, which aligns with the core purpose of all file modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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

@loic425 loic425 added the Maintenance CI configurations, READMEs, releases, etc. label Oct 31, 2025
@Rafikooo Rafikooo changed the base branch from 2.2 to 2.3 February 5, 2026 15:00
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: 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 between function keyword 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 ::class constant 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 between function keyword 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',
+        ])
+    ;

@TheMilek TheMilek merged commit 07aaab6 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/attribute branch February 25, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintenance CI configurations, READMEs, releases, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants