Skip to content

Commit 8c1cdf4

Browse files
committed
Homogenize PHP-CS-Fixer configuration with symfony/symfony, and run it
1 parent f26124c commit 8c1cdf4

File tree

8 files changed

+29
-22
lines changed

8 files changed

+29
-22
lines changed

.php-cs-fixer.dist.php

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,38 @@
1313
exit(0);
1414
}
1515

16-
$fileHeaderComment = <<<'EOF'
17-
This file is part of the Symfony package.
16+
$fileHeaderParts = [
17+
<<<'EOF'
18+
This file is part of the Symfony package.
1819
19-
(c) Fabien Potencier <fabien@symfony.com>
20+
(c) Fabien Potencier <fabien@symfony.com>
2021

21-
For the full copyright and license information, please view the LICENSE
22-
file that was distributed with this source code.
23-
EOF;
22+
EOF,
23+
<<<'EOF'
24+
25+
For the full copyright and license information, please view the LICENSE
26+
file that was distributed with this source code.
27+
EOF,
28+
];
2429

2530
return (new PhpCsFixer\Config())
2631
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
2732
->setRules([
33+
'@PHP71Migration' => true,
2834
'@PHPUnit75Migration:risky' => true,
2935
'@Symfony' => true,
3036
'@Symfony:risky' => true,
31-
'header_comment' => ['header' => $fileHeaderComment],
32-
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'match', 'parameters']],
37+
'protected_to_private' => false,
38+
'header_comment' => [
39+
'header' => implode('', $fileHeaderParts),
40+
'validator' => implode('', [
41+
'/',
42+
preg_quote($fileHeaderParts[0], '/'),
43+
'(?P<EXTRA>.*)??',
44+
preg_quote($fileHeaderParts[1], '/'),
45+
'/s',
46+
]),
47+
],
3348
])
3449
->setRiskyAllowed(true)
3550
->setFinder(
@@ -38,5 +53,7 @@
3853
->append([__FILE__])
3954
->notPath('#/Fixtures/#')
4055
->notPath('#/var/#')
56+
// does not work well with `fully_qualified_strict_types` rule
57+
->notPath('LiveComponent/tests/Integration/LiveComponentHydratorTest.php')
4158
)
4259
;

src/Icons/config/twig_component.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
1313

1414
use Symfony\UX\Icons\Twig\UXIconComponent;
15-
use Symfony\UX\Icons\Twig\UXIconComponentListener;
1615

1716
return static function (ContainerConfigurator $container): void {
1817
$container->services()

src/LiveComponent/src/Util/LiveAttributesCollection.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111

1212
namespace Symfony\UX\LiveComponent\Util;
1313

14-
use Twig\Environment;
15-
use Twig\Extension\EscaperExtension;
16-
use Twig\Runtime\EscaperRuntime;
17-
1814
/**
1915
* A collection of HTML attributes useful for LiveComponent.
2016
*

src/LiveComponent/src/Util/TwigAttributeHelperFactory.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\UX\LiveComponent\Util;
1313

14-
use Twig\Environment;
15-
1614
/**
1715
* Helper for building an array of attributes for the live controller element.
1816
*

src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
namespace Symfony\UX\LiveComponent\Tests\Functional\EventListener;
1313

1414
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
15-
use Symfony\Component\DomCrawler\Crawler;
16-
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
1715
use Symfony\Component\Security\Core\User\InMemoryUser;
1816
use Symfony\Component\Security\Http\Attribute\IsGranted;
1917
use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\Entity1;

src/LiveComponent/tests/Integration/EventListener/DataModelPropsSubscriberTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\UX\LiveComponent\Tests\Integration\EventListener;
1313

1414
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
15-
use Symfony\Component\HttpFoundation\Request;
1615
use Symfony\UX\LiveComponent\Tests\LiveComponentTestHelper;
1716
use Symfony\UX\TwigComponent\ComponentRenderer;
1817

src/Toolkit/src/Command/InstallComponentCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
123123
} else {
124124
$io->error(null === $componentName
125125
? '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.'
126-
: 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)))
126+
: \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)))
127127
);
128128

129129
return Command::FAILURE;

src/TwigComponent/tests/Unit/TwigPreLexerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public static function getLexTests(): iterable
168168
{% component 'foo' %}
169169
{% block content %}{% component 'bar' %}{% block content %}bar content{% endblock %}{% endcomponent %}
170170
{% endblock %}{% endcomponent %}
171-
EOF
171+
EOF,
172172
];
173173
yield 'component_where_entire_default_block_is_embedded_component_self_closing' => [
174174
<<<EOF
@@ -180,7 +180,7 @@ public static function getLexTests(): iterable
180180
{% component 'foo' %}
181181
{% block content %}{{ component('bar') }}
182182
{% endblock %}{% endcomponent %}
183-
EOF
183+
EOF,
184184
];
185185

186186
yield 'component_where_entire_default_block_is_twig_embed' => [
@@ -293,7 +293,7 @@ public static function getLexTests(): iterable
293293
'src/Twig/MealPlanner.php',
294294
'templates/components/MealPlanner.html.twig',
295295
] }) }}
296-
EOF
296+
EOF,
297297
];
298298

299299
yield 'component_with_dashed_attribute' => [

0 commit comments

Comments
 (0)