Skip to content

Commit f03c7a8

Browse files
committed
chore(twig): leverage twig-cs-fixer
1 parent cd87bde commit f03c7a8

File tree

63 files changed

+325
-250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+325
-250
lines changed

.github/workflows/twig-cs-fixer.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Twig CS Fixer
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.twig'
7+
pull_request:
8+
paths:
9+
- '**.twig'
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
twig-cs-fixer:
20+
name: Twig CS Fixer
21+
runs-on: ubuntu-24.04
22+
23+
env:
24+
php-version: '8.4'
25+
steps:
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: ${{ env.php-version }}
30+
ini-values: "memory_limit=-1"
31+
coverage: none
32+
33+
- name: Checkout target branch
34+
uses: actions/checkout@v4
35+
with:
36+
ref: ${{ github.base_ref }}
37+
38+
- name: Checkout PR
39+
uses: actions/checkout@v4
40+
41+
- name: Install dependencies
42+
run: |
43+
COMPOSER_HOME="$(composer config home)"
44+
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json"
45+
export COMPOSER_ROOT_VERSION=$(grep ' VERSION = ' src/Symfony/Component/HttpKernel/Kernel.php | grep -P -o '[0-9]+\.[0-9]+').x-dev
46+
composer require --dev vincentlanglet/twig-cs-fixer:^3.7
47+
48+
- name: Run Twig CS Fixer Lint
49+
run: vendor/bin/twig-cs-fixer lint --config=.twig-cs-fixer.dist.php --report=github

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ composer.lock
33
phpunit.xml
44
.php-cs-fixer.cache
55
.php-cs-fixer.php
6+
.twig-cs-fixer.cache
7+
.twig-cs-fixer.php
68
.phpunit.result.cache
79
composer.phar
810
package.tar

.twig-cs-fixer.dist.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
$ruleset = new TwigCsFixer\Ruleset\Ruleset();
13+
$ruleset->addStandard(new TwigCsFixer\Standard\TwigCsFixer());
14+
15+
$finder = new TwigCsFixer\File\Finder();
16+
$finder->in('src/Symfony/Bridge/');
17+
$finder->in('src/Symfony/Bundle/');
18+
$finder->in('src/Symfony/Component/');
19+
$finder->exclude('Fixtures');
20+
21+
$config = new TwigCsFixer\Config\Config();
22+
$config->setCacheFile('.twig-cs-fixer.cache');
23+
$config->setRuleset($ruleset);
24+
$config->setFinder($finder);
25+
// RFC: should we allow?
26+
// $config->allowNonFixableRules();
27+
28+
return $config;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{% extends "@email/zurb_2/notification/body.html.twig" %}
1+
{% extends '@email/zurb_2/notification/body.html.twig' %}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{% extends "@email/zurb_2/notification/body.txt.twig" %}
1+
{% extends '@email/zurb_2/notification/body.txt.twig' %}

src/Symfony/Bridge/Twig/Resources/views/Email/zurb_2/notification/body.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
<head>
44
<style>
55
{% block style %}
6-
{{ source("@email/zurb_2/main.css") }}
7-
{{ source("@email/zurb_2/notification/local.css") }}
6+
{{ source('@email/zurb_2/main.css') }}
7+
{{ source('@email/zurb_2/notification/local.css') }}
88
{% endblock %}
99
</style>
1010
</head>
1111
<body>
1212
<spacer size="32"></spacer>
1313
<wrapper class="body">
14-
<container class="body_{{ ("urgent" == importance ? "alert" : ("high" == importance ? "warning" : "default")) }}">
14+
<container class="body_{{ ('urgent' == importance ? 'alert' : ('high' == importance ? 'warning' : 'default')) }}">
1515
<spacer size="16"></spacer>
1616
<row>
1717
<columns large="12" small="12">

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% use "bootstrap_3_layout.html.twig" %}
1+
{% use 'bootstrap_3_layout.html.twig' %}
22

33
{% block form_start -%}
44
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-horizontal')|trim}) %}
@@ -25,7 +25,7 @@ col-sm-2
2525
{% block form_row -%}
2626
{%- set widget_attr = {} -%}
2727
{%- if help is not empty -%}
28-
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
28+
{%- set widget_attr = {attr: {'aria-describedby': id ~ '_help'}} -%}
2929
{%- endif -%}
3030
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group' ~ ((not compound or force_error|default(false)) and not valid ? ' has-error'))|trim})} %}{{ block('attributes') }}{% endwith %}>
3131
{{- form_label(form) -}}
@@ -34,24 +34,24 @@ col-sm-2
3434
{{- form_help(form) -}}
3535
{{- form_errors(form) -}}
3636
</div>
37-
{##}</div>
37+
{# #}</div>
3838
{%- endblock form_row %}
3939

4040
{% block submit_row -%}
41-
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#}
42-
<div class="{{ block('form_label_class') }}"></div>{#--#}
41+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group')|trim})} %}{{ block('attributes') }}{% endwith %}>{#- -#}
42+
<div class="{{ block('form_label_class') }}"></div>{#- -#}
4343
<div class="{{ block('form_group_class') }}">
4444
{{- form_widget(form) -}}
45-
</div>{#--#}
45+
</div>{#- -#}
4646
</div>
4747
{%- endblock submit_row %}
4848

4949
{% block reset_row -%}
50-
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#}
51-
<div class="{{ block('form_label_class') }}"></div>{#--#}
50+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group')|trim})} %}{{ block('attributes') }}{% endwith %}>{#- -#}
51+
<div class="{{ block('form_label_class') }}"></div>{#- -#}
5252
<div class="{{ block('form_group_class') }}">
5353
{{- form_widget(form) -}}
54-
</div>{#--#}
54+
</div>{#- -#}
5555
</div>
5656
{%- endblock reset_row %}
5757

@@ -60,12 +60,12 @@ col-sm-10
6060
{%- endblock form_group_class %}
6161

6262
{% block checkbox_row -%}
63-
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group' ~ (not valid ? ' has-error'))|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#}
64-
<div class="{{ block('form_label_class') }}"></div>{#--#}
63+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group' ~ (not valid ? ' has-error'))|trim})} %}{{ block('attributes') }}{% endwith %}>{#- -#}
64+
<div class="{{ block('form_label_class') }}"></div>{#- -#}
6565
<div class="{{ block('form_group_class') }}">
6666
{{- form_widget(form) -}}
6767
{{- form_help(form) -}}
6868
{{- form_errors(form) -}}
69-
</div>{#--#}
69+
</div>{#- -#}
7070
</div>
7171
{%- endblock checkbox_row %}

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% use "bootstrap_base_layout.html.twig" %}
1+
{% use 'bootstrap_base_layout.html.twig' %}
22

33
{# Widgets #}
44

@@ -35,21 +35,21 @@
3535
{% block checkbox_widget -%}
3636
{%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%}
3737
{% if 'checkbox-inline' in parent_label_class %}
38-
{{- form_label(form, null, { widget: parent() }) -}}
38+
{{- form_label(form, null, {widget: parent()}) -}}
3939
{% else -%}
4040
<div class="checkbox">
41-
{{- form_label(form, null, { widget: parent() }) -}}
41+
{{- form_label(form, null, {widget: parent()}) -}}
4242
</div>
4343
{%- endif -%}
4444
{%- endblock checkbox_widget %}
4545

4646
{% block radio_widget -%}
4747
{%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%}
4848
{%- if 'radio-inline' in parent_label_class -%}
49-
{{- form_label(form, null, { widget: parent() }) -}}
49+
{{- form_label(form, null, {widget: parent()}) -}}
5050
{%- else -%}
5151
<div class="radio">
52-
{{- form_label(form, null, { widget: parent() }) -}}
52+
{{- form_label(form, null, {widget: parent()}) -}}
5353
</div>
5454
{%- endif -%}
5555
{%- endblock radio_widget %}
@@ -73,13 +73,13 @@
7373
{% endblock %}
7474

7575
{% block checkbox_label -%}
76-
{%- set label_attr = label_attr|merge({'for': id}) -%}
76+
{%- set label_attr = label_attr|merge({for: id}) -%}
7777

7878
{{- block('checkbox_radio_label') -}}
7979
{%- endblock checkbox_label %}
8080

8181
{% block radio_label -%}
82-
{%- set label_attr = label_attr|merge({'for': id}) -%}
82+
{%- set label_attr = label_attr|merge({for: id}) -%}
8383

8484
{{- block('checkbox_radio_label') -}}
8585
{%- endblock radio_label %}
@@ -104,7 +104,7 @@
104104
{% set label = name|humanize %}
105105
{%- endif -%}
106106
{%- endif -%}
107-
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
107+
<label{% with {attr: label_attr} %}{{ block('attributes') }}{% endwith %}>
108108
{#- if statement must be kept on the same line, to force the space between widget and label -#}
109109
{{- widget|raw }} {% if label is not same as(false) -%}
110110
{%- if translation_domain is same as(false) -%}
@@ -130,7 +130,7 @@
130130
{% block form_row -%}
131131
{%- set widget_attr = {} -%}
132132
{%- if help is not empty -%}
133-
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
133+
{%- set widget_attr = {attr: {'aria-describedby': id ~ '_help'}} -%}
134134
{%- endif -%}
135135
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group' ~ ((not compound or force_error|default(false)) and not valid ? ' has-error'))|trim})} %}{{ block('attributes') }}{% endwith %}>
136136
{{- form_label(form) }} {# -#}
@@ -201,7 +201,7 @@
201201
{% block form_help -%}
202202
{%- if help is not empty -%}
203203
{%- set help_attr = help_attr|merge({class: (help_attr.class|default('') ~ ' help-block')|trim}) -%}
204-
<span id="{{ id }}_help"{% with { attr: help_attr } %}{{ block('attributes') }}{% endwith %}>
204+
<span id="{{ id }}_help"{% with {attr: help_attr} %}{{ block('attributes') }}{% endwith %}>
205205
{%- if translation_domain is same as(false) -%}
206206
{%- if help_html is same as(false) -%}
207207
{{- help -}}

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_horizontal_layout.html.twig

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% use "bootstrap_4_layout.html.twig" %}
1+
{% use 'bootstrap_4_layout.html.twig' %}
22

33
{# Labels #}
44

@@ -26,22 +26,22 @@ col-sm-2
2626
{%- else -%}
2727
{%- set widget_attr = {} -%}
2828
{%- if help is not empty -%}
29-
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
29+
{%- set widget_attr = {attr: {'aria-describedby': id ~ '_help'}} -%}
3030
{%- endif -%}
3131
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group row' ~ ((not compound or force_error|default(false)) and not valid ? ' is-invalid'))|trim})} %}{{ block('attributes') }}{% endwith %}>
3232
{{- form_label(form) -}}
3333
<div class="{{ block('form_group_class') }}">
3434
{{- form_widget(form, widget_attr) -}}
3535
{{- form_help(form) -}}
3636
</div>
37-
{##}</div>
37+
{# #}</div>
3838
{%- endif -%}
3939
{%- endblock form_row %}
4040

4141
{% block fieldset_form_row -%}
4242
{%- set widget_attr = {} -%}
4343
{%- if help is not empty -%}
44-
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
44+
{%- set widget_attr = {attr: {'aria-describedby': id ~ '_help'}} -%}
4545
{%- endif -%}
4646
<fieldset{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group')|trim})} %}{{ block('attributes') }}{% endwith %}>
4747
<div class="row{% if (not compound or force_error|default(false)) and not valid %} is-invalid{% endif %}">
@@ -52,24 +52,24 @@ col-sm-2
5252
{{- form_errors(form) -}}
5353
</div>
5454
</div>
55-
{##}</fieldset>
55+
{# #}</fieldset>
5656
{%- endblock fieldset_form_row %}
5757

5858
{% block submit_row -%}
59-
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group row')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#}
60-
<div class="{{ block('form_label_class') }}"></div>{#--#}
59+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group row')|trim})} %}{{ block('attributes') }}{% endwith %}>{#- -#}
60+
<div class="{{ block('form_label_class') }}"></div>{#- -#}
6161
<div class="{{ block('form_group_class') }}">
6262
{{- form_widget(form) -}}
63-
</div>{#--#}
63+
</div>{#- -#}
6464
</div>
6565
{%- endblock submit_row %}
6666

6767
{% block reset_row -%}
68-
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group row')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#}
69-
<div class="{{ block('form_label_class') }}"></div>{#--#}
68+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group row')|trim})} %}{{ block('attributes') }}{% endwith %}>{#- -#}
69+
<div class="{{ block('form_label_class') }}"></div>{#- -#}
7070
<div class="{{ block('form_group_class') }}">
7171
{{- form_widget(form) -}}
72-
</div>{#--#}
72+
</div>{#- -#}
7373
</div>
7474
{%- endblock reset_row %}
7575

@@ -78,11 +78,11 @@ col-sm-10
7878
{%- endblock form_group_class %}
7979

8080
{% block checkbox_row -%}
81-
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group row')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#}
82-
<div class="{{ block('form_label_class') }}"></div>{#--#}
81+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group row')|trim})} %}{{ block('attributes') }}{% endwith %}>{#- -#}
82+
<div class="{{ block('form_label_class') }}"></div>{#- -#}
8383
<div class="{{ block('form_group_class') }}">
8484
{{- form_widget(form) -}}
8585
{{- form_help(form) -}}
86-
</div>{#--#}
86+
</div>{#- -#}
8787
</div>
8888
{%- endblock checkbox_row %}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy