From a33c5852718b9763bf0c5d967d19cbe8327dbdf6 Mon Sep 17 00:00:00 2001 From: Gennadi McKelvey Date: Sat, 19 Nov 2022 22:01:12 +0100 Subject: [PATCH] only set private if true --- deptrac.config.php | 3 ++- src/Contract/Config/Collector/BoolConfig.php | 2 +- src/Contract/Config/CollectorConfig.php | 11 +++++++---- src/Contract/Config/DeptracConfig.php | 16 ++++++++-------- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/deptrac.config.php b/deptrac.config.php index 5b5f5ced4..9f4bf09d8 100755 --- a/deptrac.config.php +++ b/deptrac.config.php @@ -62,7 +62,7 @@ ), $outputFormatter = Layer::withName('OutputFormatter')->collectors( DirectoryConfig::public('src/Supportive/OutputFormatter/.*'), - ClassNameConfig::private(regex('^phpDocumentor\\\\GraphViz\\\\.*')), + ClassNameConfig::private(regex('^phpDocumentor\\GraphViz\\.*')), ), $file = Layer::withName('File')->collectors( DirectoryConfig::public('src/Supportive/File/.*') @@ -86,6 +86,7 @@ ) ->formatters( GraphvizConfig::create() + ->pointsToGroup(true) ->groups('Contract', $contract) ->groups('Supportive', $supportive, $file) ->groups('Symfony', $console, $dependencyInjection, $outputFormatter) diff --git a/src/Contract/Config/Collector/BoolConfig.php b/src/Contract/Config/Collector/BoolConfig.php index e811fb81e..a385af1bc 100644 --- a/src/Contract/Config/Collector/BoolConfig.php +++ b/src/Contract/Config/Collector/BoolConfig.php @@ -46,8 +46,8 @@ public function withMust(CollectorConfig $CollectorConfig): self public function toArray(): array { return parent::toArray() + [ - 'must' => array_map(static fn (CollectorConfig $v) => $v->toArray(), $this->must), 'must_not' => array_map(static fn (CollectorConfig $v) => $v->toArray(), $this->mustNot), + 'must' => array_map(static fn (CollectorConfig $v) => $v->toArray(), $this->must), ]; } } diff --git a/src/Contract/Config/CollectorConfig.php b/src/Contract/Config/CollectorConfig.php index 28c61a0fe..1fabdfdcd 100644 --- a/src/Contract/Config/CollectorConfig.php +++ b/src/Contract/Config/CollectorConfig.php @@ -17,9 +17,12 @@ protected function __construct( */ public function toArray(): array { - return [ - 'type' => $this->collectorType->value, - 'private' => $this->private, - ]; + if ($this->private) { + $output['private'] = $this->private; + } + + $output['type'] = $this->collectorType->value; + + return $output; } } diff --git a/src/Contract/Config/DeptracConfig.php b/src/Contract/Config/DeptracConfig.php index 1ff47572e..a81f34190 100644 --- a/src/Contract/Config/DeptracConfig.php +++ b/src/Contract/Config/DeptracConfig.php @@ -98,6 +98,14 @@ public function toArray(): array $config['paths'] = $this->paths; } + if ([] !== $this->analyser) { + $config['analyser']['types'] = array_map(static fn (EmitterType $emitterType) => $emitterType->value, $this->analyser); + } + + if ([] !== $this->formatters) { + $config['formatters'] = array_map(static fn (FormatterConfigInterface $formatterConfig) => $formatterConfig->toArray(), $this->formatters); + } + if ([] !== $this->excludeFiles) { $config['exclude_files'] = $this->excludeFiles; } @@ -114,14 +122,6 @@ public function toArray(): array $config['skip_violations'] = $this->skipViolations; } - if ([] !== $this->formatters) { - $config['formatters'] = array_map(static fn (FormatterConfigInterface $formatterConfig) => $formatterConfig->toArray(), $this->formatters); - } - - if ([] !== $this->skipViolations) { - $config['analyser']['types'] = array_map(static fn (EmitterType $emitterType) => $emitterType->value, $this->analyser); - } - $config['ignore_uncovered_internal_classes'] = $this->ignoreUncoveredInternalClasses; $config['use_relative_path_from_depfile'] = $this->useRelativePathFromDepfile;