From 30d6045acbf12e0da32f77457f207bbdf97cdde1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 24 Jan 2026 07:32:29 +0000 Subject: [PATCH] add support for twig-cs-fixer Adds detection for Twig-CS-Fixer based on the presence of `.twig-cs-fixer.php` or `.twig-cs-fixer.dist.php` configuration files. Signed-off-by: Guillaume Sainthillier --- README.md | 1 + src/tools.ts | 2 ++ src/tools/twigCsFixer.ts | 10 ++++++++++ .../code-check-twig-cs-fixer-php-dist/.laminas-ci.json | 3 +++ .../.twig-cs-fixer.dist.php | 1 + tests/code-check-twig-cs-fixer-php-dist/matrix.json | 10 ++++++++++ tests/code-check-twig-cs-fixer-php-dist/test.env | 0 tests/code-check-twig-cs-fixer-php/.laminas-ci.json | 3 +++ tests/code-check-twig-cs-fixer-php/.twig-cs-fixer.php | 1 + tests/code-check-twig-cs-fixer-php/matrix.json | 10 ++++++++++ tests/code-check-twig-cs-fixer-php/test.env | 0 11 files changed, 41 insertions(+) create mode 100644 src/tools/twigCsFixer.ts create mode 100644 tests/code-check-twig-cs-fixer-php-dist/.laminas-ci.json create mode 100644 tests/code-check-twig-cs-fixer-php-dist/.twig-cs-fixer.dist.php create mode 100644 tests/code-check-twig-cs-fixer-php-dist/matrix.json create mode 100644 tests/code-check-twig-cs-fixer-php-dist/test.env create mode 100644 tests/code-check-twig-cs-fixer-php/.laminas-ci.json create mode 100644 tests/code-check-twig-cs-fixer-php/.twig-cs-fixer.php create mode 100644 tests/code-check-twig-cs-fixer-php/matrix.json create mode 100644 tests/code-check-twig-cs-fixer-php/test.env diff --git a/README.md b/README.md index ee5bd0ba..21b519a5 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ The following tools are automatically detected based on their configuration file | Composer Require Checker | `composer-require-checker.json` | | | Composer Dependency Analyser | `composer-dependency-analyser.php` | | | PHPBench | `phpbench.json` | | +| Twig-CS-Fixer | `.twig-cs-fixer.php`, `.twig-cs-fixer.dist.php` | | | Backward Compatibility Check | — | Optional; requires configuration in `.laminas-ci.json` | ### Documentation Linting diff --git a/src/tools.ts b/src/tools.ts index a99a01da..c9d6a21a 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -11,6 +11,7 @@ import {PhpBenchTool} from './tools/phpbench'; import {CodeceptionTool} from './tools/codeception'; import {PhpCsFixerTool} from './tools/phpCsFixer'; import {PHPStanTool} from './tools/phpstan'; +import {TwigCsFixerTool} from './tools/twigCsFixer'; import {ToolExecutionType} from './enum/toolExecutionType'; import {ToolType} from './enum/toolType'; @@ -86,6 +87,7 @@ export default function createTools(config: Config): Array { CodeceptionTool, PhpCsFixerTool, PHPStanTool, + TwigCsFixerTool, backwardCompatibilityCheckTool(config), ].filter((tool) => tool !== null) as Tool[]; diff --git a/src/tools/twigCsFixer.ts b/src/tools/twigCsFixer.ts new file mode 100644 index 00000000..5823fc15 --- /dev/null +++ b/src/tools/twigCsFixer.ts @@ -0,0 +1,10 @@ +import {ToolType} from '../enum/toolType'; +import {ToolExecutionType} from '../enum/toolExecutionType'; + +export const TwigCsFixerTool = { + executionType : ToolExecutionType.STATIC, + name : 'Twig CS Fixer', + command : './vendor/bin/twig-cs-fixer lint --report checkstyle | cs2pr', + filesToCheck : [ '.twig-cs-fixer.php', '.twig-cs-fixer.dist.php' ], + toolType : ToolType.CODE_CHECK, +}; diff --git a/tests/code-check-twig-cs-fixer-php-dist/.laminas-ci.json b/tests/code-check-twig-cs-fixer-php-dist/.laminas-ci.json new file mode 100644 index 00000000..a912e7b6 --- /dev/null +++ b/tests/code-check-twig-cs-fixer-php-dist/.laminas-ci.json @@ -0,0 +1,3 @@ +{ + "stablePHP": "7.4" +} diff --git a/tests/code-check-twig-cs-fixer-php-dist/.twig-cs-fixer.dist.php b/tests/code-check-twig-cs-fixer-php-dist/.twig-cs-fixer.dist.php new file mode 100644 index 00000000..b3d9bbc7 --- /dev/null +++ b/tests/code-check-twig-cs-fixer-php-dist/.twig-cs-fixer.dist.php @@ -0,0 +1 @@ +