diff --git a/.gitignore b/.gitignore index 6acb006c..ed225cb2 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,8 @@ phpstan.neon /.php-cs-fixer.php /.php-cs-fixer.cache ###< php-cs-fixer/shim ### + +###> vincentlanglet/twig-cs-fixer ### +/.twig-cs-fixer.php +/.twig-cs-fixer.cache +###< vincentlanglet/twig-cs-fixer ### diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 5e8720f4..f07fbe24 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -4,6 +4,7 @@ $finder = (new PhpCsFixer\Finder()) ->in(__DIR__) + ->ignoreDotFiles(false) ->exclude('var') ->notName('bundles.php'); diff --git a/.twig-cs-fixer.dist.php b/.twig-cs-fixer.dist.php new file mode 100644 index 00000000..878e0204 --- /dev/null +++ b/.twig-cs-fixer.dist.php @@ -0,0 +1,19 @@ +addStandard(new TwigCsFixer\Standard\TwigCsFixer()); + +$finder = new TwigCsFixer\File\Finder(); +$finder->in('templates/'); + +$config = new TwigCsFixer\Config\Config(); +$config->allowNonFixableRules(); +$config->setRuleset($ruleset); +$config->setFinder($finder); + +// $config->addTwigExtension(new Sulu\Twig\Extensions\PortalExtension()); +// $config->addTokenParser(new Sulu\Twig\Extensions\TokenParser\PortalTokenParser()); + +return $config; diff --git a/composer.json b/composer.json index 399664e6..50b8a2b5 100644 --- a/composer.json +++ b/composer.json @@ -73,7 +73,8 @@ "symfony/phpunit-bridge": "^7.1", "symfony/thanks": "^1.2", "symfony/web-profiler-bundle": "^7.1", - "thecodingmachine/phpstan-strict-rules": "^1.0" + "thecodingmachine/phpstan-strict-rules": "^1.0", + "vincentlanglet/twig-cs-fixer": "^3.0" }, "conflict": { "symfony/symfony": "*" @@ -140,6 +141,7 @@ "@lint-php-cs", "@lint-rector", "@lint-twig", + "@lint-twig-cs", "@lint-yaml", "@lint-container", "@lint-composer", @@ -147,7 +149,8 @@ ], "fix": [ "@rector", - "@php-cs-fix" + "@php-cs-fix", + "@twig-cs-fix" ], "phpstan": [ "@php bin/websiteconsole cache:warmup --env=dev", @@ -162,6 +165,8 @@ ], "php-cs-fix": "@php vendor/bin/php-cs-fixer fix", "lint-php-cs": "@php vendor/bin/php-cs-fixer fix --verbose --diff --dry-run", + "twig-cs-fix": "@php vendor/bin/twig-cs-fixer lint --fix", + "lint-twig-cs": "@php vendor/bin/twig-cs-fixer lint", "lint-composer": "@composer validate --no-check-publish --strict", "lint-twig": "@php bin/console lint:twig templates/", "lint-yaml": "@php bin/console lint:yaml config/ --parse-tags", diff --git a/symfony.lock b/symfony.lock index 2330e277..ddf947d3 100644 --- a/symfony.lock +++ b/symfony.lock @@ -357,5 +357,14 @@ "config/packages/web_profiler.yaml", "config/routes/web_profiler.yaml" ] + }, + "vincentlanglet/twig-cs-fixer": { + "version": "3.0", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "0.6", + "ref": "e4da12a48e8138479bd24a675321bcfd84950266" + } } } diff --git a/templates/base.html.twig b/templates/base.html.twig index 97f5ccc3..5cb80243 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -6,12 +6,12 @@ {% block meta %} - {% include "@SuluWebsite/Extension/seo.html.twig" with { - "seo": extension.seo|default([]), - "content": content|default([]), - "localizations": localizations|default([]), - "shadowBaseLocale": shadowBaseLocale|default(), - } %} + {{ include('@SuluWebsite/Extension/seo.html.twig', { + seo: extension.seo|default([]), + content: content|default([]), + localizations: localizations|default([]), + shadowBaseLocale: shadowBaseLocale|default(), + }) }} {% endblock %} {% block style %}{% endblock %} diff --git a/templates/error/error.html.twig b/templates/error/error.html.twig index c509845f..3b07677f 100644 --- a/templates/error/error.html.twig +++ b/templates/error/error.html.twig @@ -1,4 +1,4 @@ -{% extends "base.html.twig" %} +{% extends 'base.html.twig' %} {% block content %}

Error {{ status_code }}: {{ status_text }}

diff --git a/templates/pages/default.html.twig b/templates/pages/default.html.twig index 7e8465fd..e61a3d52 100644 --- a/templates/pages/default.html.twig +++ b/templates/pages/default.html.twig @@ -1,4 +1,4 @@ -{% extends "base.html.twig" %} +{% extends 'base.html.twig' %} {% block content %}

{{ content.title }}

diff --git a/templates/pages/homepage.html.twig b/templates/pages/homepage.html.twig index 7e8465fd..e61a3d52 100644 --- a/templates/pages/homepage.html.twig +++ b/templates/pages/homepage.html.twig @@ -1,4 +1,4 @@ -{% extends "base.html.twig" %} +{% extends 'base.html.twig' %} {% block content %}

{{ content.title }}

diff --git a/templates/search/search.html.twig b/templates/search/search.html.twig index dcb2d062..095d8df5 100644 --- a/templates/search/search.html.twig +++ b/templates/search/search.html.twig @@ -1,4 +1,4 @@ -{% extends "base.html.twig" %} +{% extends 'base.html.twig' %} {% block content %}

Showing {{ hits|length }} results for "{{ query }}"