Skip to content

Commit 0078c5d

Browse files
committed
chore(twig): leverage twig-cs-fixer
1 parent 371b671 commit 0078c5d

File tree

5 files changed

+82
-2
lines changed

5 files changed

+82
-2
lines changed

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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
50+

.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;

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"symfony/twig-bridge": "^6.4|^7.0|^8.0",
5151
"symfony/validator": "^6.4|^7.0|^8.0",
5252
"symfony/yaml": "^6.4|^7.0|^8.0",
53-
"twig/twig": "^3.12",
53+
"twig/twig": "^3.15",
5454
"web-token/jwt-library": "^3.3.2|^4.0"
5555
},
5656
"conflict": {

src/Symfony/Bundle/WebProfilerBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"symfony/http-kernel": "^6.4|^7.0|^8.0",
2525
"symfony/routing": "^6.4|^7.0|^8.0",
2626
"symfony/twig-bundle": "^6.4|^7.0|^8.0",
27-
"twig/twig": "^3.12"
27+
"twig/twig": "^3.15"
2828
},
2929
"require-dev": {
3030
"symfony/browser-kit": "^6.4|^7.0|^8.0",

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