From 8c8b78a9ee9e4879f2778e2bf273fd27431a1f4a Mon Sep 17 00:00:00 2001 From: dwarfex Date: Tue, 22 Mar 2022 10:36:14 +0100 Subject: [PATCH 1/3] update deptrac-shim - it now uses "output" instead of "xml-dump" --- composer.json | 2 +- src/Tools/Deptrac.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index f7d60b3..d1c57e4 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "phpstan/phpstan-strict-rules": "^0.12", "phpunit/phpunit": "^9.5", "psalm/plugin-phpunit": "^0.15.0", - "qossmic/deptrac-shim": "^0.13.0", + "qossmic/deptrac-shim": "^0.19.0", "rector/rector": "^0.8.56", "squizlabs/php_codesniffer": "^3.5", "symplify/easy-coding-standard-prefixed": "^9", diff --git a/src/Tools/Deptrac.php b/src/Tools/Deptrac.php index dc07475..7bc1a33 100644 --- a/src/Tools/Deptrac.php +++ b/src/Tools/Deptrac.php @@ -23,7 +23,7 @@ public function run(Context $context): bool '--formatter=xml', '--no-progress', '--no-interaction', - "--xml-dump={$outputFile}", + "--output={$outputFile}", ]) === 0 ) { return true; From a771a853a1b6da594b428fc35e2efda627cfc9e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonie=20Gr=C3=A4=C3=9Fel?= Date: Wed, 6 Apr 2022 21:31:26 +0200 Subject: [PATCH 2/3] Use new deptrac.yaml config --- depfile.yaml | 15 --------------- deptrac.yaml | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 15 deletions(-) delete mode 100644 depfile.yaml create mode 100644 deptrac.yaml diff --git a/depfile.yaml b/depfile.yaml deleted file mode 100644 index 9b91791..0000000 --- a/depfile.yaml +++ /dev/null @@ -1,15 +0,0 @@ -paths: - - ./src - - ./tests -layers: - - name: Sources - collectors: - - type: directory - regex: src/.* - - name: Tests - collectors: - - type: directory - regex: tests/.* -ruleset: - Tests: - - Sources diff --git a/deptrac.yaml b/deptrac.yaml new file mode 100644 index 0000000..30fc1fd --- /dev/null +++ b/deptrac.yaml @@ -0,0 +1,16 @@ +parameters: + paths: + - ./src + - ./tests + layers: + - name: Sources + collectors: + - type: directory + regex: src/.* + - name: Tests + collectors: + - type: directory + regex: tests/.* + ruleset: + Tests: + - Sources From 1ffc090c3ef733613c382524199cd8126578e335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonie=20Gr=C3=A4=C3=9Fel?= Date: Wed, 6 Apr 2022 21:38:09 +0200 Subject: [PATCH 3/3] Support older versions of deptrac --- src/Tools/Deptrac.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Tools/Deptrac.php b/src/Tools/Deptrac.php index 7bc1a33..83a3b32 100644 --- a/src/Tools/Deptrac.php +++ b/src/Tools/Deptrac.php @@ -9,6 +9,8 @@ use Spaceemotion\PhpCodingStandard\Formatter\Result; use Spaceemotion\PhpCodingStandard\Formatter\Violation; +use function preg_match; + class Deptrac extends Tool { /** @var string */ @@ -23,7 +25,9 @@ public function run(Context $context): bool '--formatter=xml', '--no-progress', '--no-interaction', - "--output={$outputFile}", + $this->useNewOutputFormat() + ? "--output={$outputFile}" + : "--xml-dump={$outputFile}", ]) === 0 ) { return true; @@ -60,4 +64,20 @@ public function run(Context $context): bool return false; } + + protected function useNewOutputFormat(): bool + { + $output = []; + $matches = []; + + $this->execute(self::vendorBinary('deptrac'), ['--version'], $output); + + preg_match('/(?[\d.]+)/', implode(' ', $output), $matches); + + if (isset($matches['version'])) { + return ((float) $matches['version']) >= 0.19; + } + + return false; + } }