Skip to content

Commit

Permalink
do not crash the GraphViz formatter if no config is given
Browse files Browse the repository at this point in the history
PR #951 did not fully fix #949. Reason for this is that the Symfony container
compiler skips loading extensions for which no configuration has been made.
This in turn means that the Deptrac Configuration class is never processed
and its default values are not being populated.
  • Loading branch information
xabbuh committed Jul 21, 2023
1 parent bd7cf22 commit 8215b12
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
final class ConfigurationGraphViz
{
/**
* @param array{hidden_layers: string[], groups: array<string, string[]>, point_to_groups: bool} $arr
* @param array{hidden_layers?: string[], groups?: array<string, string[]>, point_to_groups?: bool} $arr
*/
public static function fromArray(array $arr): self
{
return new self($arr['hidden_layers'], $arr['groups'], $arr['point_to_groups']);
return new self($arr['hidden_layers'] ?? [], $arr['groups'] ?? [], $arr['point_to_groups'] ?? false);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Supportive/OutputFormatter/GraphVizOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
abstract class GraphVizOutputFormatter implements OutputFormatterInterface
{
/**
* @var array{hidden_layers: string[], groups: array<string, string[]>, point_to_groups: bool}
* @var array{hidden_layers?: string[], groups?: array<string, string[]>, point_to_groups?: bool}
*/
private readonly array $config;

public function __construct(FormatterConfiguration $config)
{
/** @var array{hidden_layers: string[], groups: array<string, string[]>, point_to_groups: bool} $extractedConfig */
/** @var array{hidden_layers?: string[], groups?: array<string, string[]>, point_to_groups?: bool} $extractedConfig */
$extractedConfig = $config->getConfigFor('graphviz');
$this->config = $extractedConfig;
}
Expand Down

0 comments on commit 8215b12

Please sign in to comment.