diff --git a/psalm.xml b/psalm.xml
index 78df975..38edc2c 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -14,7 +14,7 @@
-
-
-
+
+
+
diff --git a/src/IP.php b/src/IP.php
index 8d0466d..4073e4c 100644
--- a/src/IP.php
+++ b/src/IP.php
@@ -22,6 +22,7 @@ final private function __construct(string $address)
/**
* @psalm-pure
*/
+ #[\NoDiscard]
final public static function v4(string $address): IPv4
{
if (!\filter_var($address, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) {
@@ -35,6 +36,7 @@ final public static function v4(string $address): IPv4
/**
* @psalm-pure
*/
+ #[\NoDiscard]
final public static function v6(string $address): IPv6
{
if (!\filter_var($address, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
@@ -45,6 +47,7 @@ final public static function v6(string $address): IPv6
return new IPv6($address);
}
+ #[\NoDiscard]
final public function equals(self $self): bool
{
return $this->address === $self->address;
@@ -53,6 +56,7 @@ final public function equals(self $self): bool
/**
* @return non-empty-string
*/
+ #[\NoDiscard]
final public function toString(): string
{
return $this->address;
diff --git a/src/IPv4.php b/src/IPv4.php
index 8d6dc44..c155989 100644
--- a/src/IPv4.php
+++ b/src/IPv4.php
@@ -16,6 +16,7 @@ final class IPv4 extends IP
/**
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(string $address): self
{
return IP::v4($address);
@@ -24,6 +25,7 @@ public static function of(string $address): self
/**
* @psalm-pure
*/
+ #[\NoDiscard]
public static function localhost(): self
{
return self::of('127.0.0.1');
@@ -34,6 +36,7 @@ public static function localhost(): self
*
* @return Maybe
*/
+ #[\NoDiscard]
public static function maybe(string $address): Maybe
{
return self::attempt($address)->maybe();
@@ -44,6 +47,7 @@ public static function maybe(string $address): Maybe
*
* @return Attempt
*/
+ #[\NoDiscard]
public static function attempt(string $address): Attempt
{
return Attempt::of(static fn() => self::of($address));
diff --git a/src/IPv6.php b/src/IPv6.php
index 034a826..a3a7aa3 100644
--- a/src/IPv6.php
+++ b/src/IPv6.php
@@ -16,6 +16,7 @@ final class IPv6 extends IP
/**
* @psalm-pure
*/
+ #[\NoDiscard]
public static function of(string $address): self
{
return IP::v6($address);
@@ -24,6 +25,7 @@ public static function of(string $address): self
/**
* @psalm-pure
*/
+ #[\NoDiscard]
public static function localhost(): self
{
return self::of('::1');
@@ -34,6 +36,7 @@ public static function localhost(): self
*
* @return Maybe
*/
+ #[\NoDiscard]
public static function maybe(string $address): Maybe
{
return self::attempt($address)->maybe();
@@ -44,6 +47,7 @@ public static function maybe(string $address): Maybe
*
* @return Attempt
*/
+ #[\NoDiscard]
public static function attempt(string $address): Attempt
{
return Attempt::of(static fn() => self::of($address));
diff --git a/tests/IPv4Test.php b/tests/IPv4Test.php
index 636f0ea..8b65ae4 100644
--- a/tests/IPv4Test.php
+++ b/tests/IPv4Test.php
@@ -43,7 +43,7 @@ public function testThrowWhenInvalidFormat()
$this->expectException(\DomainException::class);
$this->expectExceptionMessage('localhost');
- IPv4::of('localhost');
+ $_ = IPv4::of('localhost');
}
public function testThrowWhenOutOfBound()
@@ -51,7 +51,7 @@ public function testThrowWhenOutOfBound()
$this->expectException(\DomainException::class);
$this->expectExceptionMessage('256.0.0.1');
- IPv4::of('256.0.0.1');
+ $_ = IPv4::of('256.0.0.1');
}
public function testMaybeReturnNothingForInvalidAddress()
diff --git a/tests/IPv6Test.php b/tests/IPv6Test.php
index abffa06..05487f1 100644
--- a/tests/IPv6Test.php
+++ b/tests/IPv6Test.php
@@ -43,7 +43,7 @@ public function testThrowWhenInvalidFormat()
$this->expectException(\DomainException::class);
$this->expectExceptionMessage('localhost');
- IPv6::of('localhost');
+ $_ = IPv6::of('localhost');
}
public function testThrowWhenOutOfBound()
@@ -51,7 +51,7 @@ public function testThrowWhenOutOfBound()
$this->expectException(\DomainException::class);
$this->expectExceptionMessage('::z');
- IPv6::of('::z');
+ $_ = IPv6::of('::z');
}
public function testMaybeReturnNothingForInvalidAddress()