Skip to content

Commit

Permalink
Adding PHP8.4 support and Deprecated attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Dec 4, 2024
1 parent 631060f commit 9c88896
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ All Notable changes to `League\Uri\Interfaces` will be documented in this file
- `UriInterface::getUsername` returns the encoded user component of the URI.
- `UriInterface::getPassword` returns the encoded scheme-specific information about how to gain authorization to access the resource.
- `Uri\IPv6\Converter` allows expanding and compressing IPv6.
- `Uri\IPv4\Converter::to6to4` allows converting an IPv4 into an IPv6 host using the 6to4 notation.
- `Uri\IPv4\Converter::toIPv4MappedIPv6` allows mapping an IPv4 address into an IPv6 one.
- `Uri\IPv4\Converter::toIPv6Using6to4` allows converting an IPv4 into an IPv6 host using the 6to4 notation.
- `Uri\IPv4\Converter::toIPv6UsingMapping` allows mapping an IPv4 address into an IPv6 one.

### Fixed

- Adding Host resolution caching to speed up URI parsing in `UriString`
- `UriString::parseAuthority` accepts `Stringable` object as valid input
- `Uri\UriString::parseAuthority` accepts `Stringable` object as valid input
- `Uri\IPv4\Converter::toDecimal` also handles 6to4 and IPv4 mapped address algorithm.
- `Uri\QueryString::extract` and `QueryString::convert` stop parsing too early issue [#146](https://github.com/thephpleague/uri-src/issues/146)

### Deprecated

Expand Down
6 changes: 4 additions & 2 deletions Contracts/QueryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace League\Uri\Contracts;

use Countable;
use Deprecated;
use Iterator;
use IteratorAggregate;
use Stringable;
Expand Down Expand Up @@ -229,15 +230,16 @@ public function withPair(string $key, Stringable|string|int|float|bool|null $val
/**
* DEPRECATION WARNING! This method will be removed in the next major point release.
*
* @deprecated Since version 7.2.0
* @deprecated Since version 7.3.0
* @codeCoverageIgnore
* @see Modifier::removeQueryPairsByKey()
* @see QueryInterface::withoutPairByKey()
*
* Returns an instance without the specified keys.
*
* This method MUST retain the state of the current instance, and return
* an instance that contains the modified component
*/
#[Deprecated(message:'use League\Uri\Contracts\QueryInterface::withoutPairByKey() instead', since:'league/uri-interfaces:7.3.0')]
public function withoutPair(string ...$keys): self;

/**
Expand Down
12 changes: 6 additions & 6 deletions IPv4/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function isIpv4(Stringable|string|null $host): bool
&& false !== long2ip((int) hexdec($hexParts[0]) * 65536 + (int) hexdec($hexParts[1]));
}

public function to6to4(Stringable|string|null $host): ?string
public function toIPv6Using6to4(Stringable|string|null $host): ?string
{
$host = $this->toDecimal($host);
if (null === $host) {
Expand All @@ -146,14 +146,14 @@ public function to6to4(Stringable|string|null $host): ?string
return '['.self::IPV6_6TO4_PREFIX.$parts[0].$parts[1].':'.$parts[2].$parts[3].'::]';
}

public function toIPv4MappedIPv6(Stringable|string|null $host): ?string
public function toIPv6UsingMapping(Stringable|string|null $host): ?string
{
$host = $this->toDecimal($host);
if (null === $host) {
return null;
}

return match ($host) {
null => null,
default => '['.self::IPV4_MAPPED_PREFIX.$host.']',
};
return '['.self::IPV4_MAPPED_PREFIX.$host.']';
}

public function toOctal(Stringable|string|null $host): ?string
Expand Down
12 changes: 6 additions & 6 deletions IPv4/ConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ public function testConvertToDecimal(
self::assertSame($hexadecimal, Converter::fromNative()->toHexadecimal($input));
self::assertSame($hexadecimal, Converter::fromBCMath()->toHexadecimal($input));

self::assertSame($sixToFour, Converter::fromBCMath()->to6to4($input));
self::assertSame($sixToFour, Converter::fromNative()->to6to4($input));
self::assertSame($sixToFour, Converter::fromBCMath()->to6to4($input));
self::assertSame($sixToFour, Converter::fromBCMath()->toIPv6Using6to4($input));
self::assertSame($sixToFour, Converter::fromNative()->toIPv6Using6to4($input));
self::assertSame($sixToFour, Converter::fromBCMath()->toIPv6Using6to4($input));

self::assertSame($ipv4Mapped, Converter::fromBCMath()->toIPv4MappedIPv6($input));
self::assertSame($ipv4Mapped, Converter::fromNative()->toIPv4MappedIPv6($input));
self::assertSame($ipv4Mapped, Converter::fromBCMath()->toIPv4MappedIPv6($input));
self::assertSame($ipv4Mapped, Converter::fromBCMath()->toIPv6UsingMapping($input));
self::assertSame($ipv4Mapped, Converter::fromNative()->toIPv6UsingMapping($input));
self::assertSame($ipv4Mapped, Converter::fromBCMath()->toIPv6UsingMapping($input));

self::assertTrue(Converter::fromEnvironment()->isIpv4($input));
}
Expand Down

0 comments on commit 9c88896

Please sign in to comment.