Repository: symfony/ux
Pull request #2773 (2025-05-25 12:30:13)

[Map] Add missing dependency for spatie/phpunit-snapshot-assertions to require-dev
| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Docs?         | no <!-- required for new features -->
| Issues        | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT

<!--
Replace this notice by a description of your feature/bugfix.
This will help reviewers and should be a good start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - For new features, provide some code snippets to help understand usage.
 - Features and deprecations must be submitted against branch main.
 - Update/add documentation as required (we can help!)
 - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
 - Never break backward compatibility (see https://symfony.com/bc).
-->

There is a reference to the spatie package inside https://github.com/symfony/ux/blob/2.x/src/Map/src/Test/RendererTestCase.php#L16 



Patch:
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
index 35eb7c6c..a8c7da94 100644
--- a/.php-cs-fixer.dist.php
+++ b/.php-cs-fixer.dist.php
@@ -13,19 +13,14 @@ if (!file_exists(__DIR__.'/src')) {
     exit(0);
 }
 
-$fileHeaderParts = [
-    <<<'EOF'
-        This file is part of the Symfony package.
+$fileHeaderComment = <<<'EOF'
+This file is part of the Symfony package.
 
-        (c) Fabien Potencier <fabien@symfony.com>
+(c) Fabien Potencier <fabien@symfony.com>
 
-        EOF,
-    <<<'EOF'
-
-        For the full copyright and license information, please view the LICENSE
-        file that was distributed with this source code.
-        EOF,
-];
+For the full copyright and license information, please view the LICENSE
+file that was distributed with this source code.
+EOF;
 
 return (new PhpCsFixer\Config())
     ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
@@ -33,17 +28,8 @@ return (new PhpCsFixer\Config())
         '@PHPUnit75Migration:risky' => true,
         '@Symfony' => true,
         '@Symfony:risky' => true,
-        'protected_to_private' => false,
-        'header_comment' => [
-            'header' => implode('', $fileHeaderParts),
-            'validator' => implode('', [
-                '/',
-                preg_quote($fileHeaderParts[0], '/'),
-                '(?P<EXTRA>.*)??',
-                preg_quote($fileHeaderParts[1], '/'),
-                '/s',
-            ]),
-        ],
+        'header_comment' => ['header' => $fileHeaderComment],
+        'trailing_comma_in_multiline' => ['elements' => ['arrays', 'match', 'parameters']],
     ])
     ->setRiskyAllowed(true)
     ->setFinder(
@@ -52,7 +38,5 @@ return (new PhpCsFixer\Config())
             ->append([__FILE__])
             ->notPath('#/Fixtures/#')
             ->notPath('#/var/#')
-            // does not work well with `fully_qualified_strict_types` rule
-            ->notPath('LiveComponent/tests/Integration/LiveComponentHydratorTest.php')
     )
 ;
diff --git a/src/Icons/config/twig_component.php b/src/Icons/config/twig_component.php
index 0b65f64f..5e27cc81 100644
--- a/src/Icons/config/twig_component.php
+++ b/src/Icons/config/twig_component.php
@@ -12,6 +12,7 @@
 namespace Symfony\Component\DependencyInjection\Loader\Configurator;
 
 use Symfony\UX\Icons\Twig\UXIconComponent;
+use Symfony\UX\Icons\Twig\UXIconComponentListener;
 
 return static function (ContainerConfigurator $container): void {
     $container->services()
diff --git a/src/LiveComponent/src/Util/LiveAttributesCollection.php b/src/LiveComponent/src/Util/LiveAttributesCollection.php
index a39cbac0..c09287c9 100644
--- a/src/LiveComponent/src/Util/LiveAttributesCollection.php
+++ b/src/LiveComponent/src/Util/LiveAttributesCollection.php
@@ -11,6 +11,10 @@
 
 namespace Symfony\UX\LiveComponent\Util;
 
+use Twig\Environment;
+use Twig\Extension\EscaperExtension;
+use Twig\Runtime\EscaperRuntime;
+
 /**
  * A collection of HTML attributes useful for LiveComponent.
  *
diff --git a/src/LiveComponent/src/Util/TwigAttributeHelperFactory.php b/src/LiveComponent/src/Util/TwigAttributeHelperFactory.php
index 68b7ccf2..9f729ce8 100644
--- a/src/LiveComponent/src/Util/TwigAttributeHelperFactory.php
+++ b/src/LiveComponent/src/Util/TwigAttributeHelperFactory.php
@@ -11,6 +11,8 @@
 
 namespace Symfony\UX\LiveComponent\Util;
 
+use Twig\Environment;
+
 /**
  * Helper for building an array of attributes for the live controller element.
  *
diff --git a/src/Map/composer.json b/src/Map/composer.json
index c08fcb87..909e090e 100644
--- a/src/Map/composer.json
+++ b/src/Map/composer.json
@@ -41,7 +41,9 @@
         "symfony/phpunit-bridge": "^7.2",
         "symfony/twig-bundle": "^6.4|^7.0",
         "symfony/ux-twig-component": "^2.18",
-        "symfony/ux-icons": "^2.18"
+        "symfony/ux-icons": "^2.18",
+        "spatie/phpunit-snapshot-assertions": "^4.2.17",
+        "phpunit/phpunit": "^9.6.22"
     },
     "conflict": {
         "symfony/ux-twig-component": "<2.21"
diff --git a/src/Map/doc/index.rst b/src/Map/doc/index.rst
index b45ae091..d1e886d7 100644
--- a/src/Map/doc/index.rst
+++ b/src/Map/doc/index.rst
@@ -109,6 +109,10 @@ You can add markers to a map using the ``addMarker()`` method::
                 headerContent: '<b>Lyon</b>',
                 content: 'The French town in the historic Rhône-Alpes region, located at the junction of the Rhône and Saône rivers.'
             ),
+            icon: new Icon(
+                content: '<svg>....</svg>'
+                icontType: 'html'
+            )
         ))
 
         // You can also pass arbitrary data via the `extra` option in both the marker
diff --git a/src/Map/src/Renderer/Renderers.php b/src/Map/src/Renderer/Renderers.php
index ea6262ab..ea7fae8e 100644
--- a/src/Map/src/Renderer/Renderers.php
+++ b/src/Map/src/Renderer/Renderers.php
@@ -57,7 +57,7 @@ final class Renderers implements RendererInterface
         return $renderer->renderMap($map, $attributes);
     }
 
-    public function __toString(): string
+    public function __toString()
     {
         return implode(', ', array_keys($this->renderers));
     }
diff --git a/src/Toolkit/src/Command/InstallComponentCommand.php b/src/Toolkit/src/Command/InstallComponentCommand.php
index 6746a6d5..83dd56ee 100644
--- a/src/Toolkit/src/Command/InstallComponentCommand.php
+++ b/src/Toolkit/src/Command/InstallComponentCommand.php
@@ -123,7 +123,7 @@ EOF
             } else {
                 $io->error(null === $componentName
                     ? 'It seems that no local kits are available and it should not happens. Please open an issue on https://github.com/symfony/ux to report this.'
-                    : \sprintf("The component \"%s\" does not exist in any local kits.\n\nYou can try to run one of the following commands to interactively install components:\n%s\n\nOr you can try one of the community kits https://github.com/search?q=topic:ux-toolkit&type=repositories", $componentName, implode("\n", array_map(fn (string $availableKitName) => \sprintf('$ bin/console %s --kit %s', $this->getName(), $availableKitName), $availableKitNames)))
+                    : sprintf("The component \"%s\" does not exist in any local kits.\n\nYou can try to run one of the following commands to interactively install components:\n%s\n\nOr you can try one of the community kits https://github.com/search?q=topic:ux-toolkit&type=repositories", $componentName, implode("\n", array_map(fn (string $availableKitName) => sprintf('$ bin/console %s --kit %s', $this->getName(), $availableKitName), $availableKitNames)))
                 );
 
                 return Command::FAILURE;


Test patch:
diff --git a/src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php b/src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php
index c5141554..9ac59da9 100644
--- a/src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php
+++ b/src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php
@@ -12,6 +12,8 @@
 namespace Symfony\UX\LiveComponent\Tests\Functional\EventListener;
 
 use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
+use Symfony\Component\DomCrawler\Crawler;
+use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
 use Symfony\Component\Security\Core\User\InMemoryUser;
 use Symfony\Component\Security\Http\Attribute\IsGranted;
 use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\Entity1;
diff --git a/src/LiveComponent/tests/Integration/EventListener/DataModelPropsSubscriberTest.php b/src/LiveComponent/tests/Integration/EventListener/DataModelPropsSubscriberTest.php
index 60d1f6e6..1d04d03d 100644
--- a/src/LiveComponent/tests/Integration/EventListener/DataModelPropsSubscriberTest.php
+++ b/src/LiveComponent/tests/Integration/EventListener/DataModelPropsSubscriberTest.php
@@ -12,6 +12,7 @@
 namespace Symfony\UX\LiveComponent\Tests\Integration\EventListener;
 
 use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
+use Symfony\Component\HttpFoundation\Request;
 use Symfony\UX\LiveComponent\Tests\LiveComponentTestHelper;
 use Symfony\UX\TwigComponent\ComponentRenderer;
 
diff --git a/src/TwigComponent/tests/Unit/TwigPreLexerTest.php b/src/TwigComponent/tests/Unit/TwigPreLexerTest.php
index 6165cab3..2878fb3b 100644
--- a/src/TwigComponent/tests/Unit/TwigPreLexerTest.php
+++ b/src/TwigComponent/tests/Unit/TwigPreLexerTest.php
@@ -168,7 +168,7 @@ final class TwigPreLexerTest extends TestCase
             {% component 'foo' %}
                 {% block content %}{% component 'bar' %}{% block content %}bar content{% endblock %}{% endcomponent %}
             {% endblock %}{% endcomponent %}
-            EOF,
+            EOF
         ];
         yield 'component_where_entire_default_block_is_embedded_component_self_closing' => [
             <<<EOF
@@ -180,7 +180,7 @@ final class TwigPreLexerTest extends TestCase
             {% component 'foo' %}
                 {% block content %}{{ component('bar') }}
             {% endblock %}{% endcomponent %}
-            EOF,
+            EOF
         ];
 
         yield 'component_where_entire_default_block_is_twig_embed' => [
@@ -293,7 +293,7 @@ final class TwigPreLexerTest extends TestCase
                 'src/Twig/MealPlanner.php',
                 'templates/components/MealPlanner.html.twig',
             ] }) }}
-            EOF,
+            EOF
         ];
 
         yield 'component_with_dashed_attribute' => [