Skip to content

Homogenize PHP-CS-Fixer configuration with symfony/symfony, and run it #2768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,37 @@
exit(0);
}

$fileHeaderComment = <<<'EOF'
This file is part of the Symfony package.
$fileHeaderParts = [
<<<'EOF'
This file is part of the Symfony package.

(c) Fabien Potencier <fabien@symfony.com>
(c) Fabien Potencier <fabien@symfony.com>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;
EOF,
<<<'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())
->setRules([
'@PHPUnit75Migration:risky' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'header_comment' => ['header' => $fileHeaderComment],
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'match', 'parameters']],
'protected_to_private' => false,
'header_comment' => [
'header' => implode('', $fileHeaderParts),
'validator' => implode('', [
'/',
preg_quote($fileHeaderParts[0], '/'),
'(?P<EXTRA>.*)??',
preg_quote($fileHeaderParts[1], '/'),
'/s',
]),
],
])
->setRiskyAllowed(true)
->setFinder(
Expand All @@ -38,5 +52,7 @@
->append([__FILE__])
->notPath('#/Fixtures/#')
->notPath('#/var/#')
// does not work well with `fully_qualified_strict_types` rule
->notPath('LiveComponent/tests/Integration/LiveComponentHydratorTest.php')
)
;
1 change: 0 additions & 1 deletion src/Icons/config/twig_component.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 0 additions & 4 deletions src/LiveComponent/src/Util/LiveAttributesCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
2 changes: 0 additions & 2 deletions src/LiveComponent/src/Util/TwigAttributeHelperFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Symfony\UX\LiveComponent\Util;

use Twig\Environment;

/**
* Helper for building an array of attributes for the live controller element.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Toolkit/src/Command/InstallComponentCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/TwigComponent/tests/Unit/TwigPreLexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
<<<EOF
Expand All @@ -180,7 +180,7 @@ public static function getLexTests(): iterable
{% component 'foo' %}
{% block content %}{{ component('bar') }}
{% endblock %}{% endcomponent %}
EOF
EOF,
];

yield 'component_where_entire_default_block_is_twig_embed' => [
Expand Down Expand Up @@ -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' => [
Expand Down
Loading