Skip to content

chore(twig): leverage twig-cs-fixer #60761

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

Open
wants to merge 2 commits into
base: 7.4
Choose a base branch
from
Open

Conversation

94noni
Copy link
Contributor

@94noni 94noni commented Jun 11, 2025

Q A
Branch? 7.4
Bug fix? no (improve Twig file coding standard consistency)
New feature? no
Deprecations? no
Issues Fix #54799
License MIT

This PR adds config file for the tool twig-cs-fixer (via)

As per the original issue, this tool is, in my opinion, relevant here to standardize symfony source Twig file,
It follows Twig recommandation, and it's since the issue creation mentioned in the official Twig doc.

How to use:

TODOs:

  • decide if its wanted/needed or not
  • act default rule set for this PR
  • define CI

Friendly ping @VincentLanglet @smnandre as issue commenters

Copy link
Member

@stof stof left a comment

Choose a reason for hiding this comment

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

this should have a GitHub Actions workflow running the tool in CI, otherwise it won't be enforced.

regarding your summary in the description, this is not a new feature. It is about tooling for contributors and CI, but it does not bring any new feature in Symfony (and does not require a mention in changelog either, as users of Symfony won't care)

@94noni
Copy link
Contributor Author

94noni commented Jun 11, 2025

this should have a GitHub Actions workflow running the tool in CI, otherwise it won't be enforced.

totally agree,
the main idea here is really to see how it behaves on the codebase as per issue comment

and does not require a mention in changelog either

top make sens, lets not add it and update the desc

@94noni
Copy link
Contributor Author

94noni commented Jun 12, 2025

i do think I've addressed the comments (standard to chose, exclude fixtures, and composer min)

for the adding ci, I am not so aware of best practice of it (when no vendor lock) so please review appreciated
(inspired by the psalm one and some reading)

@94noni 94noni force-pushed the dev-twig-cs branch 4 times, most recently from f03c7a8 to 5559cb7 Compare June 12, 2025 07:46
@94noni 94noni changed the title chore(twig): leveragetwig-cs-fixer chore(twig): leverage twig-cs-fixer Jun 12, 2025
fabpot added a commit to twigphp/Twig that referenced this pull request Jun 15, 2025
…nglet)

This PR was merged into the 3.x branch.

Discussion
----------

Coding standard suggestion about empty content

Hi `@fabpot`

As suggested by `@stof` symfony/symfony#60761 (comment)

This would allow writing `{#--#}` rather than `{#- -#}` when following the twig coding standard.

Commits
-------

0b93a1f Stof suggestion about empty content
@94noni
Copy link
Contributor Author

94noni commented Jun 18, 2025

PR updated to use latest version
split in 2 commits; first being the real code, second being the tool run on codebase

Comment on lines +33 to +36
- name: Checkout target branch
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
Copy link

Choose a reason for hiding this comment

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

Suggested change
- name: Checkout target branch
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
- name: Checkout
uses: actions/checkout@v4

Please note that in this case a PR branch is required, not a target branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] include a new dev config file for twig-cs-fixer in the codebase
6 participants