Skip to content

Commit b0ee8ae

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

File tree

61 files changed

+274
-249
lines changed

Some content is hidden

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

61 files changed

+274
-249
lines changed

.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: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
$ruleset->addRule(new TwigCsFixer\Rules\Function\IncludeFunctionRule());
15+
16+
$finder = new TwigCsFixer\File\Finder();
17+
$finder->in('src/Symfony/Bridge/')->exclude('Twig/Tests/Fixtures/extractor/');
18+
$finder->in('src/Symfony/Bundle/');
19+
$finder->in('src/Symfony/Component/');
20+
21+
$config = new TwigCsFixer\Config\Config();
22+
$config->setCacheFile('.twig-cs-fixer.cache');
23+
$config->setRuleset($ruleset);
24+
$config->setFinder($finder);
25+
// $config->allowNonFixableRules();
26+
27+
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 %}

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

Lines changed: 14 additions & 14 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

@@ -123,10 +123,10 @@
123123
{%- set type = type|default('file') -%}
124124
{%- set input_lang = 'en' -%}
125125
{% if app is defined and app.request is defined %}{%- set input_lang = app.request.locale -%}{%- endif -%}
126-
{%- set attr = {lang: input_lang} | merge(attr) -%}
126+
{%- set attr = {lang: input_lang}|merge(attr) -%}
127127
{{- block('form_widget_simple') -}}
128-
{%- set label_attr = label_attr|merge({ class: (label_attr.class|default('') ~ ' custom-file-label')|trim })|filter((value, key) => key != 'id') -%}
129-
<label for="{{ form.vars.id }}" {% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
128+
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' custom-file-label')|trim})|filter((value, key) => key != 'id') -%}
129+
<label for="{{ form.vars.id }}" {% with {attr: label_attr} %}{{ block('attributes') }}{% endwith %}>
130130
{%- if attr.placeholder is defined and attr.placeholder is not none -%}
131131
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
132132
{%- endif -%}
@@ -173,17 +173,17 @@
173173
{%- if 'checkbox-custom' in parent_label_class -%}
174174
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' custom-control-input')|trim}) -%}
175175
<div class="custom-control custom-checkbox{{ 'checkbox-inline' in parent_label_class ? ' custom-control-inline' }}">
176-
{{- form_label(form, null, { widget: parent() }) -}}
176+
{{- form_label(form, null, {widget: parent()}) -}}
177177
</div>
178178
{%- elseif 'switch-custom' in parent_label_class -%}
179179
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' custom-control-input')|trim}) -%}
180180
<div class="custom-control custom-switch{{ 'switch-inline' in parent_label_class ? ' custom-control-inline' }}">
181-
{{- form_label(form, null, { widget: parent() }) -}}
181+
{{- form_label(form, null, {widget: parent()}) -}}
182182
</div>
183183
{%- else -%}
184184
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-check-input')|trim}) -%}
185185
<div class="form-check{{ 'checkbox-inline' in parent_label_class ? ' form-check-inline' }}">
186-
{{- form_label(form, null, { widget: parent() }) -}}
186+
{{- form_label(form, null, {widget: parent()}) -}}
187187
</div>
188188
{%- endif -%}
189189
{%- endblock checkbox_widget %}
@@ -193,12 +193,12 @@
193193
{%- if 'radio-custom' in parent_label_class -%}
194194
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' custom-control-input')|trim}) -%}
195195
<div class="custom-control custom-radio{{ 'radio-inline' in parent_label_class ? ' custom-control-inline' }}">
196-
{{- form_label(form, null, { widget: parent() }) -}}
196+
{{- form_label(form, null, {widget: parent()}) -}}
197197
</div>
198198
{%- else -%}
199199
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-check-input')|trim}) -%}
200200
<div class="form-check{{ 'radio-inline' in parent_label_class ? ' form-check-inline' }}">
201-
{{- form_label(form, null, { widget: parent() }) -}}
201+
{{- form_label(form, null, {widget: parent()}) -}}
202202
</div>
203203
{%- endif -%}
204204
{%- endblock radio_widget %}
@@ -233,7 +233,7 @@
233233
{% if required -%}
234234
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %}
235235
{%- endif -%}
236-
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>
236+
<{{ element|default('label') }}{% if label_attr %}{% with {attr: label_attr} %}{{ block('attributes') }}{% endwith %}{% endif %}>
237237
{{- block('form_label_content') -}}
238238
{% block form_label_errors %}{{- form_errors(form) -}}{% endblock form_label_errors %}</{{ element|default('label') }}>
239239
{%- else -%}
@@ -256,7 +256,7 @@
256256
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' form-check-label')|trim}) -%}
257257
{%- endif %}
258258
{%- if not compound -%}
259-
{% set label_attr = label_attr|merge({'for': id}) %}
259+
{% set label_attr = label_attr|merge({for: id}) %}
260260
{%- endif -%}
261261
{%- if required -%}
262262
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%}
@@ -267,7 +267,7 @@
267267
{% endif %}
268268

269269
{{ widget|raw }}
270-
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
270+
<label{% with {attr: label_attr} %}{{ block('attributes') }}{% endwith %}>
271271
{%- if label is not same as(false) -%}
272272
{{- block('form_label_content') -}}
273273
{%- endif -%}
@@ -284,7 +284,7 @@
284284
{%- endif -%}
285285
{%- set widget_attr = {} -%}
286286
{%- if help is not empty -%}
287-
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
287+
{%- set widget_attr = {attr: {'aria-describedby': id ~ '_help'}} -%}
288288
{%- endif -%}
289289
<{{ element|default('div') }}{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group')|trim})} %}{{ block('attributes') }}{% endwith %}>
290290
{{- form_label(form) -}}
@@ -312,7 +312,7 @@
312312
{% block form_help -%}
313313
{%- if help is not empty -%}
314314
{%- set help_attr = help_attr|merge({class: (help_attr.class|default('') ~ ' form-text text-muted')|trim}) -%}
315-
<small id="{{ id }}_help"{% with { attr: help_attr } %}{{ block('attributes') }}{% endwith %}>
315+
<small id="{{ id }}_help"{% with {attr: help_attr} %}{{ block('attributes') }}{% endwith %}>
316316
{{- block('form_help_content') -}}
317317
</small>
318318
{%- endif -%}

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