Skip to content

Rename isPublicUse() to isGloballyReachable() - #107

Merged
zanbaldwin merged 1 commit into
6.xfrom
z/globally-reachable
Jun 8, 2026
Merged

Rename isPublicUse() to isGloballyReachable()#107
zanbaldwin merged 1 commit into
6.xfrom
z/globally-reachable

Conversation

@zanbaldwin

Copy link
Copy Markdown
Member

Conform to official wording from the IANA special-purpose address registries; Public Use does not appear in them. Keep isPublicUse() as a deprecated alias.

@zanbaldwin zanbaldwin self-assigned this Jun 4, 2026
@greptile-apps

greptile-apps Bot commented Jun 5, 2026

Copy link
Copy Markdown

Greptile Summary

This PR renames isPublicUse() to isGloballyReachable() across the interface, concrete implementations, docs, and tests to align with official IANA special-purpose address registry wording. The deprecated isPublicUse() is kept as a thin delegation alias in all three concrete classes.

  • IpInterface.php gains a @deprecated-annotated isPublicUse() declaration and the newly named isGloballyReachable() declaration; all three concrete classes (IPv4, IPv6, Multi) delegate the old method to the new one.
  • Test data provider constants (PUBLIC_USE_V4, PUBLIC_USE_V6, PUBLIC_USE) are renamed in the test-internal IpDataProviderInterface and the test methods are updated to exercise isGloballyReachable(); the darsyn/ip-doctrine companion repo has no usages of either method.

Confidence Score: 5/5

Safe to merge — the rename is a straightforward delegation refactor with no logic changes; the deprecated alias correctly calls through to the new method in all three concrete classes.

Every concrete class delegates isPublicUse() to isGloballyReachable(), carrying the original implementation unchanged. The darsyn/ip-doctrine companion repo has no usages of either method, so there is no cross-repo breakage risk. The only gap is the missing deprecated-alias row in the API reference doc, which is a documentation cosmetic rather than a behavioral defect.

docs/10-api.md — the deprecated isPublicUse() alias is absent from the reference table, which may confuse upgrading consumers.

Important Files Changed

Filename Overview
src/IpInterface.php Adds deprecated isPublicUse() declaration before new isGloballyReachable() declaration; both are correctly present in the interface
src/Version/IPv4.php Splits old isPublicUse() into a deprecated delegation stub plus a new isGloballyReachable() with the original logic; correct
src/Version/IPv6.php Same delegation refactor as IPv4; logic unchanged, delegation correct
src/Version/Multi.php Delegation split correctly maintained; isGloballyReachable() still dispatches to IPv4::isGloballyReachable() for embedded addresses and IPv6::isGloballyReachable() otherwise
tests/DataProvider/IpDataProviderInterface.php Test-internal constants renamed; bit values unchanged so all category bitmask logic still valid
docs/10-api.md API table updated to show isGloballyReachable(); the deprecated isPublicUse() alias is not listed

Sequence Diagram

sequenceDiagram
    participant Caller
    participant IpInterface
    participant IPv4/IPv6/Multi

    Note over IpInterface: isPublicUse() @deprecated<br/>isGloballyReachable()

    Caller->>IPv4/IPv6/Multi: isPublicUse()
    IPv4/IPv6/Multi->>IPv4/IPv6/Multi: isGloballyReachable()
    IPv4/IPv6/Multi-->>Caller: bool

    Caller->>IPv4/IPv6/Multi: isGloballyReachable()
    IPv4/IPv6/Multi-->>Caller: bool

    Note over IPv4/IPv6/Multi: Multi: embedded → IPv4::isGloballyReachable()<br/>non-embedded → IPv6::isGloballyReachable()
Loading

Reviews (2): Last reviewed commit: "feature: ✨ rename isPublicUse() to isGlo..." | Re-trigger Greptile

Comment thread src/Version/IPv4.php
Comment on lines 415 to 428

/**
* @test
* @dataProvider \Darsyn\IP\Tests\DataProvider\IPv4::getPublicUseIpAddresses()
* @dataProvider \Darsyn\IP\Tests\DataProvider\IPv4::getGloballyReachableIpAddresses()
*/
#[PHPUnit\Test]
#[PHPUnit\DataProviderExternal(IPv4DataProvider::class, 'getPublicUseIpAddresses')]
public function testIsPublicUse(string $value, bool $isPublicUse): void
#[PHPUnit\DataProviderExternal(IPv4DataProvider::class, 'getGloballyReachableIpAddresses')]
public function testIsGloballyReachable(string $value, bool $isGloballyReachable): void
{
$ip = IP::factory($value);
$this->assertSame($isPublicUse, $ip->isPublicUse());
$this->assertSame($isGloballyReachable, $ip->isGloballyReachable());
}

/**

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 No test coverage for the deprecated isPublicUse() alias

All three test classes (IPv4Test, IPv6Test, MultiTest) had their testIsPublicUse methods renamed to testIsGloballyReachable, which now only exercises the new method. The deprecated isPublicUse() delegate is completely untested — a future refactor that accidentally breaks the delegation (e.g., returning a hardcoded value) would go undetected. A minimal parameterised test that calls isPublicUse() and asserts it matches isGloballyReachable() would guard the alias.

@zanbaldwin zanbaldwin added the enhancement Existing feature enhancement (patch version bump) label Jun 7, 2026
Conform to official wording from the IANA special-purpose address registries; "Public Use" does not appear in them.
Keep isPublicUse() as a deprecated alias.
@zanbaldwin
zanbaldwin force-pushed the z/globally-reachable branch from 4eda87d to a194240 Compare June 8, 2026 12:10
@zanbaldwin
zanbaldwin merged commit 9e34d03 into 6.x Jun 8, 2026
24 checks passed
@zanbaldwin
zanbaldwin deleted the z/globally-reachable branch June 8, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Existing feature enhancement (patch version bump)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant