diff --git a/psalm.xml b/psalm.xml
index 510148d..feccc34 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -14,4 +14,7 @@
+
+
+
diff --git a/src/CallFrame.php b/src/CallFrame.php
index 59536b2..d43fe93 100644
--- a/src/CallFrame.php
+++ b/src/CallFrame.php
@@ -13,6 +13,9 @@ interface CallFrame
/**
* @return Sequence
*/
+ #[\NoDiscard]
public function arguments(): Sequence;
+
+ #[\NoDiscard]
public function toString(): string;
}
diff --git a/src/CallFrame/FunctionCall.php b/src/CallFrame/FunctionCall.php
index e72914a..b143aee 100644
--- a/src/CallFrame/FunctionCall.php
+++ b/src/CallFrame/FunctionCall.php
@@ -39,6 +39,7 @@ private function __construct(
* @no-named-arguments
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(
FunctionName $functionName,
Url $file,
@@ -48,30 +49,35 @@ public static function of(
return new self($functionName, $file, $line, ...$arguments);
}
+ #[\NoDiscard]
public function functionName(): FunctionName
{
return $this->functionName;
}
#[\Override]
+ #[\NoDiscard]
public function file(): Url
{
return $this->file;
}
#[\Override]
+ #[\NoDiscard]
public function line(): Line
{
return $this->line;
}
#[\Override]
+ #[\NoDiscard]
public function arguments(): Sequence
{
return $this->arguments;
}
#[\Override]
+ #[\NoDiscard]
public function toString(): string
{
return "{$this->functionName->toString()}()";
diff --git a/src/CallFrame/InternalFunctionCall.php b/src/CallFrame/InternalFunctionCall.php
index 3362457..c96fb30 100644
--- a/src/CallFrame/InternalFunctionCall.php
+++ b/src/CallFrame/InternalFunctionCall.php
@@ -31,23 +31,27 @@ private function __construct(FunctionName $functionName, mixed ...$arguments)
* @no-named-arguments
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(FunctionName $functionName, mixed ...$arguments): self
{
return new self($functionName, ...$arguments);
}
+ #[\NoDiscard]
public function functionName(): FunctionName
{
return $this->functionName;
}
#[\Override]
+ #[\NoDiscard]
public function arguments(): Sequence
{
return $this->arguments;
}
#[\Override]
+ #[\NoDiscard]
public function toString(): string
{
return "{$this->functionName->toString()}()";
diff --git a/src/CallFrame/InternalMethodCall.php b/src/CallFrame/InternalMethodCall.php
index b7d0379..c2831b2 100644
--- a/src/CallFrame/InternalMethodCall.php
+++ b/src/CallFrame/InternalMethodCall.php
@@ -37,6 +37,7 @@ private function __construct(
* @no-named-arguments
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(
ClassName $class,
Method $method,
@@ -45,23 +46,27 @@ public static function of(
return new self($class, $method, ...$arguments);
}
+ #[\NoDiscard]
public function class(): ClassName
{
return $this->class;
}
+ #[\NoDiscard]
public function method(): Method
{
return $this->method;
}
#[\Override]
+ #[\NoDiscard]
public function arguments(): Sequence
{
return $this->arguments;
}
#[\Override]
+ #[\NoDiscard]
public function toString(): string
{
return "{$this->class->toString()}->{$this->method->toString()}()";
diff --git a/src/CallFrame/InternalStaticMethodCall.php b/src/CallFrame/InternalStaticMethodCall.php
index a1c3f8c..808f74d 100644
--- a/src/CallFrame/InternalStaticMethodCall.php
+++ b/src/CallFrame/InternalStaticMethodCall.php
@@ -37,6 +37,7 @@ private function __construct(
* @no-named-arguments
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(
ClassName $class,
Method $method,
@@ -45,23 +46,27 @@ public static function of(
return new self($class, $method, ...$arguments);
}
+ #[\NoDiscard]
public function class(): ClassName
{
return $this->class;
}
+ #[\NoDiscard]
public function method(): Method
{
return $this->method;
}
#[\Override]
+ #[\NoDiscard]
public function arguments(): Sequence
{
return $this->arguments;
}
#[\Override]
+ #[\NoDiscard]
public function toString(): string
{
return "{$this->class->toString()}::{$this->method->toString()}()";
diff --git a/src/CallFrame/MethodCall.php b/src/CallFrame/MethodCall.php
index d58052b..32947a6 100644
--- a/src/CallFrame/MethodCall.php
+++ b/src/CallFrame/MethodCall.php
@@ -43,6 +43,7 @@ private function __construct(
* @no-named-arguments
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(
ClassName $class,
Method $method,
@@ -53,35 +54,41 @@ public static function of(
return new self($class, $method, $file, $line, ...$arguments);
}
+ #[\NoDiscard]
public function class(): ClassName
{
return $this->class;
}
+ #[\NoDiscard]
public function method(): Method
{
return $this->method;
}
#[\Override]
+ #[\NoDiscard]
public function file(): Url
{
return $this->file;
}
#[\Override]
+ #[\NoDiscard]
public function line(): Line
{
return $this->line;
}
#[\Override]
+ #[\NoDiscard]
public function arguments(): Sequence
{
return $this->arguments;
}
#[\Override]
+ #[\NoDiscard]
public function toString(): string
{
return "{$this->class->toString()}->{$this->method->toString()}()";
diff --git a/src/CallFrame/StaticMethodCall.php b/src/CallFrame/StaticMethodCall.php
index a591cf6..6ed3f78 100644
--- a/src/CallFrame/StaticMethodCall.php
+++ b/src/CallFrame/StaticMethodCall.php
@@ -43,6 +43,7 @@ private function __construct(
* @no-named-arguments
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(
ClassName $class,
Method $method,
@@ -53,35 +54,41 @@ public static function of(
return new self($class, $method, $file, $line, ...$arguments);
}
+ #[\NoDiscard]
public function class(): ClassName
{
return $this->class;
}
+ #[\NoDiscard]
public function method(): Method
{
return $this->method;
}
#[\Override]
+ #[\NoDiscard]
public function file(): Url
{
return $this->file;
}
#[\Override]
+ #[\NoDiscard]
public function line(): Line
{
return $this->line;
}
#[\Override]
+ #[\NoDiscard]
public function arguments(): Sequence
{
return $this->arguments;
}
#[\Override]
+ #[\NoDiscard]
public function toString(): string
{
return "{$this->class->toString()}::{$this->method->toString()}()";
diff --git a/src/CallFrame/UserLand.php b/src/CallFrame/UserLand.php
index e1ff505..08aabbb 100644
--- a/src/CallFrame/UserLand.php
+++ b/src/CallFrame/UserLand.php
@@ -14,6 +14,9 @@
*/
interface UserLand extends CallFrame
{
+ #[\NoDiscard]
public function file(): Url;
+
+ #[\NoDiscard]
public function line(): Line;
}
diff --git a/src/CallFrames.php b/src/CallFrames.php
index 67f2e1a..5a0a68e 100644
--- a/src/CallFrames.php
+++ b/src/CallFrames.php
@@ -13,6 +13,7 @@ final class CallFrames
*
* @return Sequence
*/
+ #[\NoDiscard]
public static function of(\Throwable $throwable): Sequence
{
$frames = [];
diff --git a/src/ClassName.php b/src/ClassName.php
index ac47080..9320692 100644
--- a/src/ClassName.php
+++ b/src/ClassName.php
@@ -25,11 +25,13 @@ private function __construct(string $value)
/**
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(string $value): self
{
return new self($value);
}
+ #[\NoDiscard]
public function toString(): string
{
return $this->value;
diff --git a/src/FormatPath.php b/src/FormatPath.php
index 6c7204a..dc71244 100644
--- a/src/FormatPath.php
+++ b/src/FormatPath.php
@@ -13,5 +13,6 @@ interface FormatPath
/**
* @return non-empty-string
*/
+ #[\NoDiscard]
public function __invoke(Url $url, Line $line): string;
}
diff --git a/src/FormatPath/Truncate.php b/src/FormatPath/Truncate.php
index 3effa7b..ab9126b 100644
--- a/src/FormatPath/Truncate.php
+++ b/src/FormatPath/Truncate.php
@@ -37,6 +37,7 @@ public function __invoke(Url $url, Line $line): string
/**
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(Url $workingDirectory): self
{
return new self($workingDirectory);
diff --git a/src/FunctionName.php b/src/FunctionName.php
index 255fcbd..fa36ea2 100644
--- a/src/FunctionName.php
+++ b/src/FunctionName.php
@@ -25,11 +25,13 @@ private function __construct(string $value)
/**
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(string $value): self
{
return new self($value);
}
+ #[\NoDiscard]
public function toString(): string
{
return $this->value;
diff --git a/src/Line.php b/src/Line.php
index 4340a5c..180fe32 100644
--- a/src/Line.php
+++ b/src/Line.php
@@ -24,16 +24,19 @@ private function __construct(int $value)
/**
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(int $value): self
{
return new self($value);
}
+ #[\NoDiscard]
public function toInt(): int
{
return $this->value;
}
+ #[\NoDiscard]
public function toString(): string
{
return (string) $this->value;
diff --git a/src/Link.php b/src/Link.php
index d326c43..8ec29d4 100644
--- a/src/Link.php
+++ b/src/Link.php
@@ -10,5 +10,6 @@
*/
interface Link
{
+ #[\NoDiscard]
public function __invoke(Url $file, Line $line): Url;
}
diff --git a/src/Method.php b/src/Method.php
index 0d40e41..090573b 100644
--- a/src/Method.php
+++ b/src/Method.php
@@ -25,11 +25,13 @@ private function __construct(string $value)
/**
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(string $value): self
{
return new self($value);
}
+ #[\NoDiscard]
public function toString(): string
{
return $this->value;
diff --git a/src/Render.php b/src/Render.php
index e28b35c..2136b68 100644
--- a/src/Render.php
+++ b/src/Render.php
@@ -33,6 +33,7 @@ private function __construct(?Link $link = null, ?FormatPath $formatPath = null)
$this->formatPath = $formatPath ?? new FormatPath\FullPath;
}
+ #[\NoDiscard]
public function __invoke(StackTrace $stack): Content
{
$thrown = $this->thrown(
@@ -63,6 +64,7 @@ public function __invoke(StackTrace $stack): Content
/**
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(?Link $link = null, ?FormatPath $formatPath = null): self
{
return new self($link, $formatPath);
diff --git a/src/StackTrace.php b/src/StackTrace.php
index 77be9ab..68f755e 100644
--- a/src/StackTrace.php
+++ b/src/StackTrace.php
@@ -29,11 +29,13 @@ private function __construct(\Throwable $e)
/**
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(\Throwable $e): self
{
return new self($e);
}
+ #[\NoDiscard]
public function throwable(): Throwable
{
return $this->throwable;
@@ -42,6 +44,7 @@ public function throwable(): Throwable
/**
* @return Sequence
*/
+ #[\NoDiscard]
public function previous(): Sequence
{
return $this->previous;
diff --git a/src/Throwable.php b/src/Throwable.php
index 9b24fcb..d46912b 100644
--- a/src/Throwable.php
+++ b/src/Throwable.php
@@ -38,31 +38,37 @@ private function __construct(\Throwable $e)
/**
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(\Throwable $e): self
{
return new self($e);
}
+ #[\NoDiscard]
public function class(): ClassName
{
return $this->class;
}
+ #[\NoDiscard]
public function code(): int
{
return $this->code;
}
+ #[\NoDiscard]
public function message(): Str
{
return $this->message;
}
+ #[\NoDiscard]
public function file(): Url
{
return $this->file;
}
+ #[\NoDiscard]
public function line(): Line
{
return $this->line;
@@ -71,6 +77,7 @@ public function line(): Line
/**
* @return Sequence
*/
+ #[\NoDiscard]
public function trace(): Sequence
{
return $this->trace;
@@ -79,6 +86,7 @@ public function trace(): Sequence
/**
* @return Sequence
*/
+ #[\NoDiscard]
public function callFrames(): Sequence
{
return $this->frames;
diff --git a/tests/ClassNameTest.php b/tests/ClassNameTest.php
index dd3e8a1..d59de0d 100644
--- a/tests/ClassNameTest.php
+++ b/tests/ClassNameTest.php
@@ -30,6 +30,6 @@ public function testThrowWhenEmptyValue()
{
$this->expectException(DomainException::class);
- ClassName::of('');
+ $_ = ClassName::of('');
}
}
diff --git a/tests/FunctionNameTest.php b/tests/FunctionNameTest.php
index 49c135c..97dd51d 100644
--- a/tests/FunctionNameTest.php
+++ b/tests/FunctionNameTest.php
@@ -30,6 +30,6 @@ public function testThrowWhenEmptyValue()
{
$this->expectException(DomainException::class);
- FunctionName::of('');
+ $_ = FunctionName::of('');
}
}
diff --git a/tests/LineTest.php b/tests/LineTest.php
index d97ddf2..357d725 100644
--- a/tests/LineTest.php
+++ b/tests/LineTest.php
@@ -31,7 +31,7 @@ public function testThrowWhenZero()
{
$this->expectException(DomainException::class);
- Line::of(0);
+ $_ = Line::of(0);
}
public function testThrowWhenNegativeValue(): BlackBox\Proof
@@ -41,7 +41,7 @@ public function testThrowWhenNegativeValue(): BlackBox\Proof
->prove(function(int $int): void {
$this->expectException(DomainException::class);
- Line::of($int);
+ $_ = Line::of($int);
});
}
}
diff --git a/tests/MethodTest.php b/tests/MethodTest.php
index 9f3a546..36a4106 100644
--- a/tests/MethodTest.php
+++ b/tests/MethodTest.php
@@ -30,6 +30,6 @@ public function testThrowWhenEmptyValue()
{
$this->expectException(DomainException::class);
- Method::of('');
+ $_ = Method::of('');
}
}