Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<UndefinedAttributeClass errorLevel="suppress" />
</issueHandlers>
</psalm>
13 changes: 13 additions & 0 deletions src/Edge.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ private function __construct(
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function between(Name $from, Name $to): self
{
/** @var Map<string, string> */
Expand All @@ -38,26 +39,31 @@ public static function between(Name $from, Name $to): self
return new self($from, $to, $attributes);
}

#[\NoDiscard]
public function from(): Name
{
return $this->from;
}

#[\NoDiscard]
public function to(): Name
{
return $this->to;
}

#[\NoDiscard]
public function asBidirectional(): self
{
return $this->with('dir', 'both');
}

#[\NoDiscard]
public function withoutDirection(): self
{
return $this->with('dir', 'none');
}

#[\NoDiscard]
public function shaped(
Shape $shape,
?Shape $shape2 = null,
Expand Down Expand Up @@ -85,6 +91,7 @@ public function shaped(
/**
* @param non-empty-string $label
*/
#[\NoDiscard]
public function displayAs(string $label): self
{
return $this->with(
Expand All @@ -93,11 +100,13 @@ public function displayAs(string $label): self
);
}

#[\NoDiscard]
public function useColor(RGBA $color): self
{
return $this->with('color', $color->toString());
}

#[\NoDiscard]
public function target(Url $url): self
{
return $this->with(
Expand All @@ -106,16 +115,19 @@ public function target(Url $url): self
);
}

#[\NoDiscard]
public function dotted(): self
{
return $this->with('style', 'dotted');
}

#[\NoDiscard]
public function bold(): self
{
return $this->with('style', 'bold');
}

#[\NoDiscard]
public function filled(): self
{
return $this->with('style', 'filled');
Expand All @@ -126,6 +138,7 @@ public function filled(): self
*
* @return Map<string, string>
*/
#[\NoDiscard]
public function attributes(): Map
{
return $this->attributes;
Expand Down
12 changes: 12 additions & 0 deletions src/Edge/Shape.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum Shape
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function box(): self
{
return self::box;
Expand All @@ -31,6 +32,7 @@ public static function box(): self
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function crow(): self
{
return self::crow;
Expand All @@ -39,6 +41,7 @@ public static function crow(): self
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function curve(): self
{
return self::curve;
Expand All @@ -47,6 +50,7 @@ public static function curve(): self
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function icurve(): self
{
return self::icurve;
Expand All @@ -55,6 +59,7 @@ public static function icurve(): self
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function diamond(): self
{
return self::diamond;
Expand All @@ -63,6 +68,7 @@ public static function diamond(): self
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function dot(): self
{
return self::dot;
Expand All @@ -71,6 +77,7 @@ public static function dot(): self
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function inv(): self
{
return self::inv;
Expand All @@ -79,6 +86,7 @@ public static function inv(): self
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function none(): self
{
return self::none;
Expand All @@ -87,6 +95,7 @@ public static function none(): self
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function normal(): self
{
return self::normal;
Expand All @@ -95,6 +104,7 @@ public static function normal(): self
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function tee(): self
{
return self::tee;
Expand All @@ -103,11 +113,13 @@ public static function tee(): self
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function vee(): self
{
return self::vee;
}

#[\NoDiscard]
public function toString(): string
{
return $this->name;
Expand Down
14 changes: 14 additions & 0 deletions src/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ private function __construct(
*
* @return self<'directed'>
*/
#[\NoDiscard]
public static function directed(string $name = 'G', ?Rankdir $rankdir = null): self
{
/** @var Set<Node> */
Expand All @@ -67,6 +68,7 @@ public static function directed(string $name = 'G', ?Rankdir $rankdir = null): s
*
* @return self<'undirected'>
*/
#[\NoDiscard]
public static function undirected(string $name = 'G', ?Rankdir $rankdir = null): self
{
/** @var Set<Node> */
Expand All @@ -83,11 +85,13 @@ public static function undirected(string $name = 'G', ?Rankdir $rankdir = null):
return new self('undirected', Name::of($name), $nodes, $clusters, $attributes);
}

#[\NoDiscard]
public function isDirected(): bool
{
return $this->directed === 'directed';
}

#[\NoDiscard]
public function name(): Name
{
return $this->name;
Expand All @@ -98,6 +102,7 @@ public function name(): Name
*
* @return self<T>
*/
#[\NoDiscard]
public function cluster(self $cluster): self
{
return new self(
Expand All @@ -112,6 +117,7 @@ public function cluster(self $cluster): self
/**
* @return Set<self<T>>
*/
#[\NoDiscard]
public function clusters(): Set
{
return $this->clusters;
Expand All @@ -120,6 +126,7 @@ public function clusters(): Set
/**
* @return self<T>
*/
#[\NoDiscard]
public function add(Node $node): self
{
return new self(
Expand All @@ -136,6 +143,7 @@ public function add(Node $node): self
*
* @return Set<Node>
*/
#[\NoDiscard]
public function roots(): Set
{
$targeted = $this
Expand All @@ -154,6 +162,7 @@ public function roots(): Set
*
* @return Set<Node>
*/
#[\NoDiscard]
public function nodes(): Set
{
return $this->nodes;
Expand All @@ -165,6 +174,7 @@ public function nodes(): Set
*
* @return self<T>
*/
#[\NoDiscard]
public function displayAs(string $label): self
{
return new self(
Expand All @@ -182,6 +192,7 @@ public function displayAs(string $label): self
/**
* @return self<T>
*/
#[\NoDiscard]
public function fillWithColor(RGBA $color): self
{
return new self(
Expand All @@ -198,6 +209,7 @@ public function fillWithColor(RGBA $color): self
/**
* @return self<T>
*/
#[\NoDiscard]
public function colorizeBorderWith(RGBA $color): self
{
return new self(
Expand All @@ -212,6 +224,7 @@ public function colorizeBorderWith(RGBA $color): self
/**
* @return self<T>
*/
#[\NoDiscard]
public function target(Url $url): self
{
return new self(
Expand All @@ -231,6 +244,7 @@ public function target(Url $url): self
*
* @return Map<string, string>
*/
#[\NoDiscard]
public function attributes(): Map
{
return $this->attributes;
Expand Down
2 changes: 2 additions & 0 deletions src/Graph/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ private function __construct(
*
* @throws DomainException
*/
#[\NoDiscard]
public static function of(string $name): self
{
if (!Str::of($name)->matches('~[a-zA-Z0-9_]+~')) {
Expand All @@ -38,6 +39,7 @@ public static function of(string $name): self
/**
* @return non-empty-string
*/
#[\NoDiscard]
public function toString(): string
{
return $this->value;
Expand Down
1 change: 1 addition & 0 deletions src/Graph/Rankdir.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum Rankdir
case leftToRight;
case topToBottom;

#[\NoDiscard]
public function toString(): string
{
return match ($this) {
Expand Down
2 changes: 2 additions & 0 deletions src/Layout/DPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ private function __construct(
*
* @param int<1, max> $value
*/
#[\NoDiscard]
public static function of(int $value): self
{
return new self($value);
Expand All @@ -29,6 +30,7 @@ public static function of(int $value): self
/**
* @return int<1, max>
*/
#[\NoDiscard]
public function toInt(): int
{
return $this->value;
Expand Down
2 changes: 2 additions & 0 deletions src/Layout/Dot.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private function __construct(
) {
}

#[\NoDiscard]
public function __invoke(Graph $graph): Content
{
$type = $graph->isDirected() ? 'digraph' : 'graph';
Expand All @@ -47,6 +48,7 @@ public function __invoke(Graph $graph): Content
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function of(?DPI $dpi = null): self
{
return new self(Maybe::of($dpi));
Expand Down
Loading