IpAddress::fromString improvements #9

Closed
opened 2026-04-27 17:55:06 +02:00 by c.fahner · 1 comment
Owner

Finding while working on slendium/http-superglobals#1: the SocketAddress interface explicitly expects an Ipv4Address|Ipv6Address while IpAddress::fromString() returns only the generic IpAddress type. This means type guards would have to be added every time this method interacts with a SocketAddress, adding unnecessary work. Additionally the fromString methods on both Ipv4Address, Ipv6Address and IpAddress should include Exception as part of their return types to enforce handling all possible cases.

This issue changes IpAddress::fromString() to return Ipv4Address|Ipv6Address|Exception. Likewise with the ipv4 and ipv6 variants of this method.

Finding while working on slendium/http-superglobals#1: the `SocketAddress` interface explicitly expects an `Ipv4Address|Ipv6Address` while `IpAddress::fromString()` returns only the generic `IpAddress` type. This means type guards would have to be added every time this method interacts with a `SocketAddress`, adding unnecessary work. Additionally the `fromString` methods on both `Ipv4Address`, `Ipv6Address` and `IpAddress` should include `Exception` as part of their return types to enforce handling all possible cases. This issue changes `IpAddress::fromString()` to return `Ipv4Address|Ipv6Address|Exception`. Likewise with the ipv4 and ipv6 variants of this method.
c.fahner added this to the v0.2 milestone 2026-04-27 17:55:06 +02:00
Author
Owner

SocketAddress is not an interface, but the method should be changed nonetheless.

`SocketAddress` is not an interface, but the method should be changed nonetheless.
c.fahner referenced this issue from a commit 2026-04-30 06:47:09 +02:00
c.fahner stopped working 2026-04-30 06:50:01 +02:00
14 minutes 5 seconds
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Total time spent: 14 minutes 5 seconds
c.fahner
14 minutes 5 seconds
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
slendium/http#9
No description provided.