Skip to content

Commit 1d17524

Browse files
authored
Use new "output" parameter instead of "xml-dump" in deptrac v0.19 (#16)
1 parent 315c05d commit 1d17524

File tree

4 files changed

+38
-17
lines changed

4 files changed

+38
-17
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"phpstan/phpstan-strict-rules": "^0.12",
3838
"phpunit/phpunit": "^9.5",
3939
"psalm/plugin-phpunit": "^0.15.0",
40-
"qossmic/deptrac-shim": "^0.13.0",
40+
"qossmic/deptrac-shim": "^0.19.0",
4141
"rector/rector": "^0.8.56",
4242
"squizlabs/php_codesniffer": "^3.5",
4343
"symplify/easy-coding-standard-prefixed": "^9",

depfile.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

deptrac.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
parameters:
2+
paths:
3+
- ./src
4+
- ./tests
5+
layers:
6+
- name: Sources
7+
collectors:
8+
- type: directory
9+
regex: src/.*
10+
- name: Tests
11+
collectors:
12+
- type: directory
13+
regex: tests/.*
14+
ruleset:
15+
Tests:
16+
- Sources

src/Tools/Deptrac.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Spaceemotion\PhpCodingStandard\Formatter\Result;
1010
use Spaceemotion\PhpCodingStandard\Formatter\Violation;
1111

12+
use function preg_match;
13+
1214
class Deptrac extends Tool
1315
{
1416
/** @var string */
@@ -23,7 +25,9 @@ public function run(Context $context): bool
2325
'--formatter=xml',
2426
'--no-progress',
2527
'--no-interaction',
26-
"--xml-dump={$outputFile}",
28+
$this->useNewOutputFormat()
29+
? "--output={$outputFile}"
30+
: "--xml-dump={$outputFile}",
2731
]) === 0
2832
) {
2933
return true;
@@ -60,4 +64,20 @@ public function run(Context $context): bool
6064

6165
return false;
6266
}
67+
68+
protected function useNewOutputFormat(): bool
69+
{
70+
$output = [];
71+
$matches = [];
72+
73+
$this->execute(self::vendorBinary('deptrac'), ['--version'], $output);
74+
75+
preg_match('/(?<version>[\d.]+)/', implode(' ', $output), $matches);
76+
77+
if (isset($matches['version'])) {
78+
return ((float) $matches['version']) >= 0.19;
79+
}
80+
81+
return false;
82+
}
6383
}

0 commit comments

Comments
 (0)