Skip to content
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
30 changes: 12 additions & 18 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (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.
*/

$fileHeaderComment = <<<COMMENT
This file is part of the Symfony package.
Expand All @@ -9,35 +18,20 @@
file that was distributed with this source code.
COMMENT;

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('config')
->exclude('var')
->exclude('public/bundles')
->exclude('public/build')
// exclude files generated by Symfony Flex recipes
->notPath('public/index.php')
->notPath('importmap.php')
;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current Finder config first includes the whole project dir and then basically excludes everything but 'src' and 'tests'. This can be simplified to include just 'src' and 'tests'.

return (new PhpCsFixer\Config())
->setFinder(
PhpCsFixer\Finder::create()->in(['src', 'tests'])->append([__FILE__])
)
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'header_comment' => ['header' => $fileHeaderComment, 'separate' => 'both'],
'linebreak_after_opening_tag' => true,
'mb_str_functions' => true,
'no_php4_constructor' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'php_unit_strict' => true,
'phpdoc_order' => true,
Copy link
Contributor Author

@rosier rosier Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule is also part of the Symfony ruleset but with a different order. To me it makes more sense for the Symfony Demo Application to use the same order as the Symfony project.

'strict_comparison' => true,
'strict_param' => true,
'blank_line_between_import_groups' => false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule is set to the opposite of the rule that is part of the Symfony ruleset. Again I think it makes more sense to follow the Symfony project.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result is pretty ugly in my opinion ... but you are completely right. Following the Symfony practices strictly should be the goal of this repository. Thanks.

])
->setFinder($finder)
->setCacheFile(__DIR__.'/var/.php-cs-fixer.cache')
;
1 change: 1 addition & 0 deletions src/Command/AddUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Stopwatch\Stopwatch;

use function Symfony\Component\String\u;

/**
Expand Down
9 changes: 5 additions & 4 deletions src/DataFixtures/AppFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\String\AbstractUnicodeString;
use Symfony\Component\String\Slugger\SluggerInterface;

use function Symfony\Component\String\u;

final class AppFixtures extends Fixture
Expand Down Expand Up @@ -127,9 +128,9 @@ private function getTagData(): array
}

/**
* @throws \Exception
*
* @return array<int, array{0: string, 1: AbstractUnicodeString, 2: string, 3: string, 4: \DateTimeImmutable, 5: User, 6: array<Tag>}>
*
* @throws \Exception
*/
private function getPostData(): array
{
Expand Down Expand Up @@ -245,9 +246,9 @@ private function getPostContent(): string
}

/**
* @throws \Exception
*
* @return array<Tag>
*
* @throws \Exception
*/
private function getRandomTags(): array
{
Expand Down
1 change: 1 addition & 0 deletions src/Entity/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

use function Symfony\Component\String\u;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

use function Symfony\Component\String\u;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Form/DataTransformer/TagArrayToStringTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use App\Entity\Tag;
use App\Repository\TagRepository;
use Symfony\Component\Form\DataTransformerInterface;

use function Symfony\Component\String\u;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Repository/PostRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use App\Pagination\Paginator;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

use function Symfony\Component\String\u;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Twig/SourceCodeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Twig\Extension\AbstractExtension;
use Twig\TemplateWrapper;
use Twig\TwigFunction;

use function Symfony\Component\String\u;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Utils/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace App\Utils;

use Symfony\Component\Console\Exception\InvalidArgumentException;

use function Symfony\Component\String\u;

/**
Expand Down