diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index a8c7da94b14..6b925439f42 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -28,8 +28,18 @@ '@PHPUnit75Migration:risky' => true, '@Symfony' => true, '@Symfony:risky' => true, + 'protected_to_private' => false, + 'no_superfluous_phpdoc_tags' => [ + 'remove_inheritdoc' => true, + 'allow_unused_params' => true, // for future-ready params, to be replaced with https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7377 + ], 'header_comment' => ['header' => $fileHeaderComment], - 'trailing_comma_in_multiline' => ['elements' => ['arrays', 'match', 'parameters']], + // TODO: Remove once the "compiler_optimized" set includes "sprintf" + 'native_function_invocation' => ['include' => ['@compiler_optimized', 'sprintf'], 'scope' => 'namespaced', 'strict' => true], + 'nullable_type_declaration' => true, + 'nullable_type_declaration_for_default_null_value' => true, + 'modernize_strpos' => true, + 'get_class_to_class_keyword' => true, ]) ->setRiskyAllowed(true) ->setFinder( diff --git a/src/Icons/config/twig_component.php b/src/Icons/config/twig_component.php index 5e27cc81ff7..0b65f64fa7a 100644 --- a/src/Icons/config/twig_component.php +++ b/src/Icons/config/twig_component.php @@ -12,7 +12,6 @@ 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 c09287c9d65..a39cbac0deb 100644 --- a/src/LiveComponent/src/Util/LiveAttributesCollection.php +++ b/src/LiveComponent/src/Util/LiveAttributesCollection.php @@ -11,10 +11,6 @@ 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 9f729ce8d28..68b7ccf264f 100644 --- a/src/LiveComponent/src/Util/TwigAttributeHelperFactory.php +++ b/src/LiveComponent/src/Util/TwigAttributeHelperFactory.php @@ -11,8 +11,6 @@ namespace Symfony\UX\LiveComponent\Util; -use Twig\Environment; - /** * Helper for building an array of attributes for the live controller element. * diff --git a/src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php b/src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php index 9ac59da9123..c5141554923 100644 --- a/src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php +++ b/src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php @@ -12,8 +12,6 @@ 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 1d04d03d6f9..60d1f6e6b3f 100644 --- a/src/LiveComponent/tests/Integration/EventListener/DataModelPropsSubscriberTest.php +++ b/src/LiveComponent/tests/Integration/EventListener/DataModelPropsSubscriberTest.php @@ -12,7 +12,6 @@ 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/LiveComponent/tests/Integration/LiveComponentHydratorTest.php b/src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php index 9df33c46c22..e00eb460b48 100644 --- a/src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php +++ b/src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php @@ -986,7 +986,7 @@ public function mount() return HydrationTest::create(new class { /** - * @var \Symfony\UX\LiveComponent\Tests\Fixtures\Dto\Address[] + * @var Address[] */ #[LiveProp(writable: true, useSerializerForHydration: true)] public array $addresses = []; @@ -1017,7 +1017,7 @@ public function mount() return HydrationTest::create(new class { /** - * @var \Symfony\UX\LiveComponent\Tests\Fixtures\Dto\Address[] + * @var Address[] */ #[LiveProp(writable: true, useSerializerForHydration: true)] public array $addresses = []; @@ -1045,7 +1045,7 @@ public function mount() yield 'Array with DTOs: fully writable allows deep partial changes' => [function () { return HydrationTest::create(new class { /** - * @var \Symfony\UX\LiveComponent\Tests\Fixtures\Dto\HoldsArrayOfDtos[] $dtos + * @var HoldsArrayOfDtos[] $dtos */ #[LiveProp(writable: true, useSerializerForHydration: true)] public array $dtos = []; @@ -1165,7 +1165,7 @@ public function mount() yield 'Collection: using serializer (de)hydrates correctly' => [function () { return HydrationTest::create(new class { - /** @var \Symfony\UX\LiveComponent\Tests\Fixtures\Dto\Temperature[] */ + /** @var Temperature[] */ #[LiveProp(useSerializerForHydration: true)] public array $temperatures = []; diff --git a/src/Toolkit/src/Command/InstallComponentCommand.php b/src/Toolkit/src/Command/InstallComponentCommand.php index 83dd56eebf9..6746a6d5272 100644 --- a/src/Toolkit/src/Command/InstallComponentCommand.php +++ b/src/Toolkit/src/Command/InstallComponentCommand.php @@ -123,7 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } 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; diff --git a/src/TwigComponent/tests/Unit/TwigPreLexerTest.php b/src/TwigComponent/tests/Unit/TwigPreLexerTest.php index 2878fb3bc74..6165cab3c75 100644 --- a/src/TwigComponent/tests/Unit/TwigPreLexerTest.php +++ b/src/TwigComponent/tests/Unit/TwigPreLexerTest.php @@ -168,7 +168,7 @@ public static function getLexTests(): iterable {% 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' => [ << [ @@ -293,7 +293,7 @@ public static function getLexTests(): iterable 'src/Twig/MealPlanner.php', 'templates/components/MealPlanner.html.twig', ] }) }} - EOF + EOF, ]; yield 'component_with_dashed_attribute' => [