diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 74c0e3b1..fb19981b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,13 +10,8 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - php: ['8.1', '8.2', '8.3'] + php: ['8.1', '8.2', '8.3', '8.4'] stability: [prefer-lowest, prefer-stable] - include: - - php: '8.4' - flags: "--ignore-platform-req=php" - phpunit-flags: '--no-coverage' - stability: prefer-stable steps: - name: Checkout code uses: actions/checkout@v3 @@ -50,11 +45,7 @@ jobs: - name: Run Unit tests with coverage run: composer phpunit -- ${{ matrix.phpunit-flags }} - if: ${{ matrix.php == '8.3' || matrix.php == '8.2' || matrix.php == '8.1' }} - - - name: Run Unit tests without coverage - run: composer phpunit:min - if: ${{ matrix.php == '8.4'}} + if: ${{ matrix.php == '8.4' || matrix.php == '8.3' || matrix.php == '8.2' || matrix.php == '8.1' }} - name: Run static analysis run: composer phpstan diff --git a/components/Components/Authority.php b/components/Components/Authority.php index afd24b6c..317d3df2 100644 --- a/components/Components/Authority.php +++ b/components/Components/Authority.php @@ -13,6 +13,7 @@ namespace League\Uri\Components; +use Deprecated; use League\Uri\Contracts\AuthorityInterface; use League\Uri\Contracts\HostInterface; use League\Uri\Contracts\PortInterface; @@ -200,6 +201,7 @@ public function withUserInfo(Stringable|string|null $user, #[SensitiveParameter] * * Create a new instance from a URI object. */ + #[Deprecated(message:'use League\Uri\Components\Authority::fromUri() instead', since:'league/uri-components:7.0.0')] public static function createFromUri(UriInterface|Psr7UriInterface $uri): self { return self::fromUri($uri); @@ -215,6 +217,7 @@ public static function createFromUri(UriInterface|Psr7UriInterface $uri): self * * Returns a new instance from a string or a stringable object. */ + #[Deprecated(message:'use League\Uri\Components\Authority::new() instead', since:'league/uri-components:7.0.0')] public static function createFromString(Stringable|string $authority): self { return self::new($authority); @@ -230,6 +233,7 @@ public static function createFromString(Stringable|string $authority): self * * Returns a new instance from null. */ + #[Deprecated(message:'use League\Uri\Components\Authority::new() instead', since:'league/uri-components:7.0.0')] public static function createFromNull(): self { return self::new(); @@ -255,6 +259,7 @@ public static function createFromNull(): self * port? : ?int * } $components */ + #[Deprecated(message:'use League\Uri\Components\Authority::fromComponents() instead', since:'league/uri-components:7.0.0')] public static function createFromComponents(array $components): self { return self::fromComponents($components); diff --git a/components/Components/DataPath.php b/components/Components/DataPath.php index c8289eb6..c510146c 100644 --- a/components/Components/DataPath.php +++ b/components/Components/DataPath.php @@ -13,6 +13,7 @@ namespace League\Uri\Components; +use Deprecated; use finfo; use League\Uri\Contracts\DataPathInterface; use League\Uri\Contracts\PathInterface; @@ -380,6 +381,7 @@ public function withParameters(Stringable|string $parameters): DataPathInterface * * Returns a new instance from a string or a stringable object. */ + #[Deprecated(message:'use League\Uri\Components\DataPath::new() instead', since:'league/uri-components:7.0.0')] public static function createFromString(Stringable|string $path): self { return self::new($path); @@ -399,6 +401,7 @@ public static function createFromString(Stringable|string $path): self * * @throws SyntaxError If the File is not readable */ + #[Deprecated(message:'use League\Uri\Components\DataPath::fromFilePath() instead', since:'league/uri-components:7.0.0')] public static function createFromFilePath(string $path, $context = null): self { return self::fromFileContents($path, $context); @@ -414,6 +417,7 @@ public static function createFromFilePath(string $path, $context = null): self * * Create a new instance from a URI object. */ + #[Deprecated(message:'use League\Uri\Components\DataPath::fromUri() instead', since:'league/uri-components:7.0.0')] public static function createFromUri(Psr7UriInterface|UriInterface $uri): self { return self::fromUri($uri); diff --git a/components/Components/Domain.php b/components/Components/Domain.php index c048429b..739026d9 100644 --- a/components/Components/Domain.php +++ b/components/Components/Domain.php @@ -13,6 +13,7 @@ namespace League\Uri\Components; +use Deprecated; use Iterator; use League\Uri\Contracts\AuthorityInterface; use League\Uri\Contracts\DomainHostInterface; @@ -304,6 +305,7 @@ public function withoutLabel(int ...$keys): DomainHostInterface * * Returns a new instance from a string or a stringable object. */ + #[Deprecated(message:'use League\Uri\Components\Domain::getIterator() instead', since:'league/uri-components:7.0.0')] public function labels(): array { return $this->labels; @@ -319,6 +321,7 @@ public function labels(): array * * Returns a new instance from a string or a stringable object. */ + #[Deprecated(message:'use League\Uri\Components\Domain::new() instead', since:'league/uri-components:7.0.0')] public static function createFromString(Stringable|string $host): self { return self::new($host); @@ -336,6 +339,7 @@ public static function createFromString(Stringable|string $host): self * * @throws TypeError If a label is the null value */ + #[Deprecated(message:'use League\Uri\Components\Domain::fromLabels() instead', since:'league/uri-components:7.0.0')] public static function createFromLabels(iterable $labels): self { return self::fromLabels(...$labels); @@ -351,6 +355,7 @@ public static function createFromLabels(iterable $labels): self * * Create a new instance from a URI object. */ + #[Deprecated(message:'use League\Uri\Components\Domain::fromUri() instead', since:'league/uri-components:7.0.0')] public static function createFromUri(Psr7UriInterface|UriInterface $uri): self { return self::fromUri($uri); @@ -366,6 +371,7 @@ public static function createFromUri(Psr7UriInterface|UriInterface $uri): self * * Create a new instance from an Authority object. */ + #[Deprecated(message:'use League\Uri\Components\Domain::fromAuthority() instead', since:'league/uri-components:7.0.0')] public static function createFromAuthority(AuthorityInterface|Stringable|string $authority): self { return self::fromAuthority($authority); @@ -381,6 +387,7 @@ public static function createFromAuthority(AuthorityInterface|Stringable|string * * Returns a new instance from an iterable structure. */ + #[Deprecated(message:'use League\Uri\Components\Domain::new() instead', since:'league/uri-components:7.0.0')] public static function createFromHost(HostInterface $host): self { return self::new($host); diff --git a/components/Components/Fragment.php b/components/Components/Fragment.php index bb1272eb..7d701878 100644 --- a/components/Components/Fragment.php +++ b/components/Components/Fragment.php @@ -13,6 +13,7 @@ namespace League\Uri\Components; +use Deprecated; use League\Uri\Contracts\FragmentInterface; use League\Uri\Contracts\UriInterface; use League\Uri\Encoder; @@ -76,6 +77,7 @@ public function decoded(): ?string * * @codeCoverageIgnore */ + #[Deprecated(message:'use League\Uri\Components\Fragment::new() instead', since:'league/uri-components:7.0.0')] public static function createFromString(Stringable|string $fragment): self { return self::new($fragment); @@ -91,6 +93,7 @@ public static function createFromString(Stringable|string $fragment): self * * Create a new instance from a URI object. */ + #[Deprecated(message:'use League\Uri\Components\Fragment::fromUri() instead', since:'league/uri-components:7.0.0')] public static function createFromUri(Psr7UriInterface|UriInterface $uri): self { return self::fromUri($uri); diff --git a/components/Components/HierarchicalPath.php b/components/Components/HierarchicalPath.php index b915e176..d3ba2026 100644 --- a/components/Components/HierarchicalPath.php +++ b/components/Components/HierarchicalPath.php @@ -13,6 +13,7 @@ namespace League\Uri\Components; +use Deprecated; use Iterator; use League\Uri\Contracts\PathInterface; use League\Uri\Contracts\SegmentedPathInterface; @@ -447,12 +448,13 @@ private function buildBasename(string $extension, string $ext, ?string $param = * DEPRECATION WARNING! This method will be removed in the next major point release. * * @deprecated Since version 7.0.0 - * @see Domain::getIterator() + * @see HierarchicalPath::getIterator() * * @codeCoverageIgnore * * Returns a new instance from a string or a stringable object. */ + #[Deprecated(message:'use League\Uri\Components\HierarchicalPath::getIterator() instead', since:'league/uri-components:7.0.0')] public function segments(): array { return $this->segments; @@ -468,6 +470,7 @@ public function segments(): array * * Returns a new instance from a string or a stringable object. */ + #[Deprecated(message:'use League\Uri\Components\HierarchicalPath::new() instead', since:'league/uri-components:7.0.0')] public static function createFromString(Stringable|string $path): self { return self::new($path); @@ -481,6 +484,7 @@ public static function createFromString(Stringable|string $path): self * * @codeCoverageIgnore */ + #[Deprecated(message:'use League\Uri\Components\HierarchicalPath::new() instead', since:'league/uri-components:7.0.0')] public static function createFromPath(PathInterface $path): self { return self::new($path); @@ -498,6 +502,7 @@ public static function createFromPath(PathInterface $path): self * * @deprecated Since version 7.0.0 */ + #[Deprecated(message:'use League\Uri\Components\HierarchicalPath::fromRelative() instead', since:'league/uri-components:7.0.0')] public static function createRelativeFromSegments(iterable $segments): self { return self::fromRelative(...$segments); @@ -515,6 +520,7 @@ public static function createRelativeFromSegments(iterable $segments): self * * @deprecated Since version 7.0.0 */ + #[Deprecated(message:'use League\Uri\Components\HierarchicalPath::fromAbsolute() instead', since:'league/uri-components:7.0.0')] public static function createAbsoluteFromSegments(iterable $segments): self { return self::fromAbsolute(...$segments); @@ -530,6 +536,7 @@ public static function createAbsoluteFromSegments(iterable $segments): self * * Create a new instance from a URI object. */ + #[Deprecated(message:'use League\Uri\Components\HierarchicalPath::fromUri() instead', since:'league/uri-components:7.0.0')] public static function createFromUri(Psr7UriInterface|UriInterface $uri): self { return self::fromUri($uri); diff --git a/components/Components/Host.php b/components/Components/Host.php index b53f2ce3..64db588e 100644 --- a/components/Components/Host.php +++ b/components/Components/Host.php @@ -13,6 +13,7 @@ namespace League\Uri\Components; +use Deprecated; use League\Uri\Contracts\AuthorityInterface; use League\Uri\Contracts\IpHostInterface; use League\Uri\Contracts\UriInterface; @@ -415,6 +416,7 @@ public function withoutZoneIdentifier(): IpHostInterface * * @codeCoverageIgnore */ + #[Deprecated(message:'use League\Uri\Components\Host::new() instead', since:'league/uri-components:7.0.0')] public static function createFromString(Stringable|string|null $host): self { return self::new($host); @@ -430,6 +432,7 @@ public static function createFromString(Stringable|string|null $host): self * * Returns a new instance from null. */ + #[Deprecated(message:'use League\Uri\Components\Host::new() instead', since:'league/uri-components:7.0.0')] public static function createFromNull(): self { return self::new(); @@ -448,6 +451,7 @@ public static function createFromNull(): self * Returns a host from an IP address. * */ + #[Deprecated(message:'use League\Uri\Components\Host::fromIp() instead', since:'league/uri-components:7.0.0')] public static function createFromIp(string $ip, string $version = '', ?IPv4Normalizer $normalizer = null): self { return self::fromIp($ip, $version); @@ -463,6 +467,7 @@ public static function createFromIp(string $ip, string $version = '', ?IPv4Norma * * Create a new instance from a URI object. */ + #[Deprecated(message:'use League\Uri\Components\Host::fromUri() instead', since:'league/uri-components:7.0.0')] public static function createFromUri(Psr7UriInterface|UriInterface $uri): self { return self::fromUri($uri); @@ -478,6 +483,7 @@ public static function createFromUri(Psr7UriInterface|UriInterface $uri): self * * Create a new instance from an Authority object. */ + #[Deprecated(message:'use League\Uri\Components\Host::fromAuthority() instead', since:'league/uri-components:7.0.0')] public static function createFromAuthority(Stringable|string $authority): self { return self::fromAuthority($authority); diff --git a/components/Components/Path.php b/components/Components/Path.php index 8d1cc44c..56aa74cc 100644 --- a/components/Components/Path.php +++ b/components/Components/Path.php @@ -13,6 +13,7 @@ namespace League\Uri\Components; +use Deprecated; use League\Uri\Contracts\PathInterface; use League\Uri\Contracts\UriInterface; use League\Uri\Encoder; @@ -169,6 +170,7 @@ public function withoutLeadingSlash(): PathInterface * * Returns a new instance from a string or a stringable object. */ + #[Deprecated(message:'use League\Uri\Components\HierarchicalPath::new() instead', since:'league/uri-components:7.0.0')] public static function createFromString(Stringable|string|int $path): self { return self::new((string) $path); @@ -184,6 +186,7 @@ public static function createFromString(Stringable|string|int $path): self * * Create a new instance from a URI object. */ + #[Deprecated(message:'use League\Uri\Components\HierarchicalPath::fromUri() instead', since:'league/uri-components:7.0.0')] public static function createFromUri(Psr7UriInterface|UriInterface $uri): self { return self::fromUri($uri); diff --git a/components/Components/Port.php b/components/Components/Port.php index 8ee8de4c..513c5b11 100644 --- a/components/Components/Port.php +++ b/components/Components/Port.php @@ -13,6 +13,7 @@ namespace League\Uri\Components; +use Deprecated; use League\Uri\Contracts\AuthorityInterface; use League\Uri\Contracts\PortInterface; use League\Uri\Contracts\UriInterface; @@ -111,6 +112,7 @@ public function toInt(): ?int * * Create a new instance from a URI object. */ + #[Deprecated(message:'use League\Uri\Components\Port::fromUri() instead', since:'league/uri-components:7.0.0')] public static function createFromUri(Psr7UriInterface|UriInterface $uri): self { return self::fromUri($uri); @@ -126,6 +128,7 @@ public static function createFromUri(Psr7UriInterface|UriInterface $uri): self * * Create a new instance from an Authority object. */ + #[Deprecated(message:'use League\Uri\Components\Port::fromAuthority() instead', since:'league/uri-components:7.0.0')] public static function createFromAuthority(AuthorityInterface|Stringable|string $authority): self { return self::fromAuthority($authority); @@ -139,6 +142,7 @@ public static function createFromAuthority(AuthorityInterface|Stringable|string * * @codeCoverageIgnore */ + #[Deprecated(message:'use League\Uri\Components\Port::new() instead', since:'league/uri-components:7.0.0')] public static function fromInt(int $port): self { return self::new($port); diff --git a/components/Components/Query.php b/components/Components/Query.php index 2f376684..ca0854d4 100644 --- a/components/Components/Query.php +++ b/components/Components/Query.php @@ -13,6 +13,7 @@ namespace League\Uri\Components; +use Deprecated; use Iterator; use League\Uri\Contracts\QueryInterface; use League\Uri\Contracts\UriComponentInterface; @@ -528,6 +529,7 @@ public function withoutParameters(string ...$names): QueryInterface * * @deprecated Since version 7.0.0 */ + #[Deprecated(message:'use League\Uri\Components\Query::fromVariables() instead', since:'league/uri-components:7.0.0')] public static function createFromParams(iterable|object $params, string $separator = '&'): self { return self::fromParameters($params, $separator); @@ -547,6 +549,7 @@ public static function createFromParams(iterable|object $params, string $separat * @param iterable $pairs * @param non-empty-string $separator */ + #[Deprecated(message:'use League\Uri\Components\Query::fromPairs() instead', since:'league/uri-components:7.0.0')] public static function createFromPairs(iterable $pairs, string $separator = '&'): self { return self::fromPairs($pairs, $separator); @@ -562,6 +565,7 @@ public static function createFromPairs(iterable $pairs, string $separator = '&') * * Create a new instance from a URI object. */ + #[Deprecated(message:'use League\Uri\Components\Query::fromUri() instead', since:'league/uri-components:7.0.0')] public static function createFromUri(Psr7UriInterface|UriInterface $uri): self { return self::fromUri($uri); @@ -579,6 +583,7 @@ public static function createFromUri(Psr7UriInterface|UriInterface $uri): self * * @param non-empty-string $separator */ + #[Deprecated(message:'use League\Uri\Components\Query::fromRFC3986() instead', since:'league/uri-components:7.0.0')] public static function createFromRFC3986(Stringable|string|int|null $query = '', string $separator = '&'): self { if (null !== $query) { @@ -600,6 +605,7 @@ public static function createFromRFC3986(Stringable|string|int|null $query = '', * * @param non-empty-string $separator */ + #[Deprecated(message:'use League\Uri\Components\Query::fromRFC1738() instead', since:'league/uri-components:7.0.0')] public static function createFromRFC1738(Stringable|string|int|null $query = '', string $separator = '&'): self { if (is_int($query)) { @@ -620,6 +626,7 @@ public static function createFromRFC1738(Stringable|string|int|null $query = '', * * Returns the query as a collection of PHP variables or a single variable assign to a specific key */ + #[Deprecated(message:'use League\Uri\Components\Query::parameter() or League\Uri\Components\Query::parameters() instead', since:'league/uri-components:7.0.0')] public function params(?string $key = null): mixed { return match (null) { @@ -636,6 +643,7 @@ public function params(?string $key = null): mixed * * @codeCoverageIgnore */ + #[Deprecated(message:'use League\Uri\Components\Query::withoutParameters() instead', since:'league/uri-components:7.0.0')] public function withoutParams(string ...$names): QueryInterface { return $this->withoutParameters(...$names); @@ -644,11 +652,12 @@ public function withoutParams(string ...$names): QueryInterface /** * DEPRECATION WARNING! This method will be removed in the next major point release. * - * @deprecated Since version 7.0.0 + * @deprecated Since version 7.3.0 * @see Query::withoutPairByKey() * * @codeCoverageIgnore */ + #[Deprecated(message:'use League\Uri\Components\Query::withoutPairByKey() instead', since:'league/uri-components:7.3.0')] public function withoutPair(string ...$keys): QueryInterface { return $this->withoutPairByKey(...$keys); @@ -666,6 +675,7 @@ public function withoutPair(string ...$keys): QueryInterface * * @deprecated Since version 7.0.0 */ + #[Deprecated(message:'use League\Uri\Components\Query::fromVariable() instead', since:'league/uri-components:7.0.0')] public static function fromParameters(object|array $parameters, string $separator = '&'): self { if ($parameters instanceof QueryInterface) { diff --git a/components/Components/Scheme.php b/components/Components/Scheme.php index cee2248c..bdf0d9cd 100644 --- a/components/Components/Scheme.php +++ b/components/Components/Scheme.php @@ -13,6 +13,7 @@ namespace League\Uri\Components; +use Deprecated; use League\Uri\Contracts\UriInterface; use League\Uri\Exceptions\SyntaxError; use League\Uri\Uri; @@ -145,6 +146,7 @@ public function getUriComponent(): string * * @codeCoverageIgnore */ + #[Deprecated(message:'use League\Uri\Components\Scheme::new() instead', since:'league/uri-components:7.0.0')] public static function createFromString(Stringable|string $scheme): self { return self::new($scheme); @@ -160,6 +162,7 @@ public static function createFromString(Stringable|string $scheme): self * * Create a new instance from a URI object. */ + #[Deprecated(message:'use League\Uri\Components\Scheme::fromUri() instead', since:'league/uri-components:7.0.0')] public static function createFromUri(Psr7UriInterface|UriInterface $uri): self { return self::fromUri($uri); diff --git a/components/Components/URLSearchParams.php b/components/Components/URLSearchParams.php index 32e92139..329a45ce 100644 --- a/components/Components/URLSearchParams.php +++ b/components/Components/URLSearchParams.php @@ -16,6 +16,7 @@ use ArgumentCountError; use Closure; use Countable; +use Deprecated; use Iterator; use IteratorAggregate; use League\Uri\Contracts\QueryInterface; @@ -501,6 +502,7 @@ public function sort(): void * @codeCoverageIgnore * */ + #[Deprecated(message:'use League\Uri\Components\URLSearchParams::fromVariable() instead', since:'league/uri-components:7.4.0')] public static function fromParameters(object|array $parameters): self { return new self(Query::fromParameters($parameters)); diff --git a/components/Components/UserInfo.php b/components/Components/UserInfo.php index b41c95f8..22a1066c 100644 --- a/components/Components/UserInfo.php +++ b/components/Components/UserInfo.php @@ -13,6 +13,7 @@ namespace League\Uri\Components; +use Deprecated; use League\Uri\Contracts\AuthorityInterface; use League\Uri\Contracts\UriComponentInterface; use League\Uri\Contracts\UriInterface; @@ -185,6 +186,7 @@ public function withPass(#[SensitiveParameter] Stringable|string|null $password) * * Create a new instance from a URI object. */ + #[Deprecated(message:'use League\Uri\Components\UserInfo::fromUri() instead', since:'league/uri-components:7.0.0')] public static function createFromUri(Psr7UriInterface|UriInterface $uri): self { return self::fromUri($uri); @@ -200,6 +202,7 @@ public static function createFromUri(Psr7UriInterface|UriInterface $uri): self * * Create a new instance from an Authority object. */ + #[Deprecated(message:'use League\Uri\Components\UserInfo::fromAuthority() instead', since:'league/uri-components:7.0.0')] public static function createFromAuthority(AuthorityInterface|Stringable|string $authority): self { return self::fromAuthority($authority); @@ -215,6 +218,7 @@ public static function createFromAuthority(AuthorityInterface|Stringable|string * * Creates a new instance from an encoded string. */ + #[Deprecated(message:'use League\Uri\Components\UserInfo::new() instead', since:'league/uri-components:7.0.0')] public static function createFromString(Stringable|string $userInfo): self { return self::new($userInfo); diff --git a/components/IPv4Normalizer.php b/components/IPv4Normalizer.php index adc85c6a..ac018dd1 100644 --- a/components/IPv4Normalizer.php +++ b/components/IPv4Normalizer.php @@ -107,7 +107,7 @@ public static function createFromNative(): self * @throws MissingFeature If no IPv4Calculator implementing object can be used on the platform * * @codeCoverageIgnore - *@see Converter::fromEnvironment() + * @see Converter::fromEnvironment() * * @codeCoverageIgnore * diff --git a/components/Modifier.php b/components/Modifier.php index ad24b905..cb295fee 100644 --- a/components/Modifier.php +++ b/components/Modifier.php @@ -13,6 +13,7 @@ namespace League\Uri; +use Deprecated; use JsonSerializable; use League\Uri\Components\DataPath; use League\Uri\Components\Domain; @@ -28,6 +29,7 @@ use League\Uri\IPv4\Converter as IPv4Converter; use League\Uri\IPv6\Converter; use League\Uri\KeyValuePair\Converter as KeyValuePairConverter; +use PHPUnit\Framework\Attributes\Test; use Psr\Http\Message\UriFactoryInterface; use Psr\Http\Message\UriInterface as Psr7UriInterface; use Stringable; @@ -46,7 +48,6 @@ final public function __construct(protected readonly Psr7UriInterface|UriInterfa /** * @param UriFactoryInterface|null $uriFactory Deprecated, will be removed in the next major release - * */ public static function from(Stringable|string $uri, ?UriFactoryInterface $uriFactory = null): static { @@ -102,7 +103,6 @@ public function __toString(): string /** * Change the encoding of the query. - * */ public function encodeQuery(KeyValuePairConverter|int $to, KeyValuePairConverter|int|null $from = null): static { @@ -207,7 +207,7 @@ public function mergeQueryPairs(iterable $pairs): self } /** - * Merge PHP query parameters with the existing URI query. + * Merge PHP query parameters with the existing URI query. */ public function mergeQueryParameters(object|array $parameters): self { @@ -795,6 +795,7 @@ final protected static function ipv4Converter(): IPv4Converter * * Remove query data according to their key name. */ + #[Deprecated(message:'use League\Uri\Modifier::removeQueryParameters() instead', since:'league/uri-components:7.2.0')] public function removeParams(string ...$keys): static { return $this->removeQueryParameters(...$keys); @@ -812,6 +813,7 @@ public function removeParams(string ...$keys): static * A pair is considered empty if it's name is the empty string * and its value is either the empty string or the null value */ + #[Deprecated(message:'use League\Uri\Modifier::removeEmptyQueryPairs() instead', since:'league/uri-components:7.2.0')] public function removeEmptyPairs(): static { return $this->removeEmptyQueryPairs(); @@ -826,6 +828,7 @@ public function removeEmptyPairs(): static * * Remove query data according to their key name. */ + #[Deprecated(message:'use League\Uri\Modifier::removeQueryPairsByKey() instead', since:'league/uri-components:7.2.0')] public function removePairs(string ...$keys): static { return $this->removeQueryPairsByKey(...$keys); @@ -840,8 +843,22 @@ public function removePairs(string ...$keys): static * * Remove query data according to their key name. */ + #[Deprecated(message:'use League\Uri\Modifier::removeQueryPairsByKey() instead', since:'league/uri-components:7.2.0')] public function removeQueryPairs(string ...$keys): static { return $this->removeQueryPairsByKey(...$keys); } + + #[Test] + public function it_will_remove_empty_pairs_fix_issue_133(): void + { + $removeEmptyPairs = fn (string $str): ?string => Modifier::from($str) + ->removeEmptyQueryPairs() + ->getUri() + ->getQuery(); + + self::assertNull($removeEmptyPairs('https://a.b/c?d=')); + self::assertNull($removeEmptyPairs('https://a.b/c?=d')); + self::assertNull($removeEmptyPairs('https://a.b/c?=')); + } } diff --git a/components/UriModifierTest.php b/components/UriModifierTest.php deleted file mode 100644 index 7f91b3df..00000000 --- a/components/UriModifierTest.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace League\Uri; - -use PHPUnit\Framework\Attributes\Test; -use PHPUnit\Framework\TestCase; - -final class UriModifierTest extends TestCase -{ - #[Test] - public function it_will_remove_empty_pairs_fix_issue_133(): void - { - $removeEmptyPairs = fn (string $str): ?string => UriModifier::removeEmptyPairs(Http::createFromString($str))->getQuery(); /* @phpstan-ignore-line */ - - self::assertSame('', $removeEmptyPairs('https://a.b/c?d=')); - self::assertSame('', $removeEmptyPairs('https://a.b/c?=d')); - self::assertSame('', $removeEmptyPairs('https://a.b/c?=')); - } -} diff --git a/interfaces/CHANGELOG.md b/interfaces/CHANGELOG.md index 1f4c53f4..7869b03a 100644 --- a/interfaces/CHANGELOG.md +++ b/interfaces/CHANGELOG.md @@ -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 diff --git a/interfaces/Contracts/QueryInterface.php b/interfaces/Contracts/QueryInterface.php index 70c2075c..fed486e3 100644 --- a/interfaces/Contracts/QueryInterface.php +++ b/interfaces/Contracts/QueryInterface.php @@ -14,6 +14,7 @@ namespace League\Uri\Contracts; use Countable; +use Deprecated; use Iterator; use IteratorAggregate; use Stringable; @@ -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; /** diff --git a/interfaces/IPv4/Converter.php b/interfaces/IPv4/Converter.php index ffdade85..71c0bb9f 100644 --- a/interfaces/IPv4/Converter.php +++ b/interfaces/IPv4/Converter.php @@ -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) { @@ -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 diff --git a/interfaces/IPv4/ConverterTest.php b/interfaces/IPv4/ConverterTest.php index 81723ad4..ffff0a4a 100644 --- a/interfaces/IPv4/ConverterTest.php +++ b/interfaces/IPv4/ConverterTest.php @@ -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)); } diff --git a/phpstan.neon b/phpstan.neon index ac1c17bb..80d10852 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -16,5 +16,6 @@ parameters: - message: '#function gmp_(.*)? expects (GMP|int)#' path: interfaces/IPv4/GMPCalculator.php - identifier: missingType.iterableValue + - '#Attribute class Deprecated does not exist.#' reportUnmatchedIgnoredErrors: true treatPhpDocTypesAsCertain: false diff --git a/uri/Http.php b/uri/Http.php index 51c23c79..0293a986 100644 --- a/uri/Http.php +++ b/uri/Http.php @@ -13,6 +13,7 @@ namespace League\Uri; +use Deprecated; use JsonSerializable; use League\Uri\Contracts\UriException; use League\Uri\Contracts\UriInterface; @@ -253,6 +254,7 @@ public function withFragment(string $fragment): self * * Create a new instance from a string. */ + #[Deprecated(message:'use League\Uri\Http::new() instead', since:'league/uri:7.0.0')] public static function createFromString(Stringable|string $uri = ''): self { return self::new($uri); @@ -270,6 +272,7 @@ public static function createFromString(Stringable|string $uri = ''): self * @param InputComponentMap $components a hash representation of the URI similar * to PHP parse_url function result */ + #[Deprecated(message:'use League\Uri\Http::fromComponents() instead', since:'league/uri:7.0.0')] public static function createFromComponents(array $components): self { return self::fromComponents($components); @@ -284,6 +287,7 @@ public static function createFromComponents(array $components): self * * Create a new instance from the environment. */ + #[Deprecated(message:'use League\Uri\Http::fromServer() instead', since:'league/uri:7.0.0')] public static function createFromServer(array $server): self { return self::fromServer($server); @@ -298,6 +302,7 @@ public static function createFromServer(array $server): self * * Create a new instance from a URI object. */ + #[Deprecated(message:'use League\Uri\Http::new() instead', since:'league/uri:7.0.0')] public static function createFromUri(Psr7UriInterface|UriInterface $uri): self { return self::new($uri); @@ -314,6 +319,7 @@ public static function createFromUri(Psr7UriInterface|UriInterface $uri): self * * The returned URI must be absolute. */ + #[Deprecated(message:'use League\Uri\Http::fromBaseUri() instead', since:'league/uri:7.0.0')] public static function createFromBaseUri(Stringable|string $uri, Stringable|string|null $baseUri = null): self { return self::fromBaseUri($uri, $baseUri); diff --git a/uri/Uri.php b/uri/Uri.php index 44737ab4..00383428 100644 --- a/uri/Uri.php +++ b/uri/Uri.php @@ -13,6 +13,7 @@ namespace League\Uri; +use Deprecated; use finfo; use League\Uri\Contracts\UriComponentInterface; use League\Uri\Contracts\UriException; @@ -692,7 +693,7 @@ private static function fetchHostname(array $server): array /** * Returns the environment path. * - * @return non-empty-array{0:?string, 1:?string} + * @return list */ private static function fetchRequestUri(array $server): array { @@ -1194,6 +1195,7 @@ public function withFragment(Stringable|string|null $fragment): UriInterface * * @return ComponentMap */ + #[Deprecated(message:'use League\Uri\Uri::toComponents() instead', since:'league/uri:7.5.0')] public function getComponents(): array { return $this->toComponents(); @@ -1206,6 +1208,7 @@ public function getComponents(): array * @codeCoverageIgnore * @see Uri::new() */ + #[Deprecated(message:'use League\Uri\Uri::new() instead', since:'league/uri:7.0.0')] public static function createFromString(Stringable|string $uri = ''): self { return self::new($uri); @@ -1220,6 +1223,7 @@ public static function createFromString(Stringable|string $uri = ''): self * * @param InputComponentMap $components a hash representation of the URI similar to PHP parse_url function result */ + #[Deprecated(message:'use League\Uri\Uri::fromComponents() instead', since:'league/uri:7.0.0')] public static function createFromComponents(array $components = []): self { return self::fromComponents($components); @@ -1237,6 +1241,7 @@ public static function createFromComponents(array $components = []): self * @deprecated Since version 7.0.0 * @codeCoverageIgnore */ + #[Deprecated(message:'use League\Uri\Uri::fromDataPath() instead', since:'league/uri:7.0.0')] public static function createFromDataPath(string $path, $context = null): self { return self::fromFileContents($path, $context); @@ -1253,6 +1258,7 @@ public static function createFromDataPath(string $path, $context = null): self * * The returned URI must be absolute. */ + #[Deprecated(message:'use League\Uri\Uri::fromBaseUri() instead', since:'league/uri:7.0.0')] public static function createFromBaseUri( Stringable|UriInterface|String $uri, Stringable|UriInterface|String|null $baseUri = null @@ -1269,6 +1275,7 @@ public static function createFromBaseUri( * * Create a new instance from a Unix path string. */ + #[Deprecated(message:'use League\Uri\Uri::fromUnixPath() instead', since:'league/uri:7.0.0')] public static function createFromUnixPath(string $uri = ''): self { return self::fromUnixPath($uri); @@ -1283,6 +1290,7 @@ public static function createFromUnixPath(string $uri = ''): self * * Create a new instance from a local Windows path string. */ + #[Deprecated(message:'use League\Uri\Uri::fromWindowsPath() instead', since:'league/uri:7.0.0')] public static function createFromWindowsPath(string $uri = ''): self { return self::fromWindowsPath($uri); @@ -1297,6 +1305,7 @@ public static function createFromWindowsPath(string $uri = ''): self * * Create a new instance from a URI object. */ + #[Deprecated(message:'use League\Uri\Uri::new() instead', since:'league/uri:7.0.0')] public static function createFromUri(Psr7UriInterface|UriInterface $uri): self { return self::new($uri); @@ -1311,6 +1320,7 @@ public static function createFromUri(Psr7UriInterface|UriInterface $uri): self * * Create a new instance from the environment. */ + #[Deprecated(message:'use League\Uri\Uri::fromServer() instead', since:'league/uri:7.0.0')] public static function createFromServer(array $server): self { return self::fromServer($server); diff --git a/uri/UriInfo.php b/uri/UriInfo.php index 80b9fa01..c782926b 100644 --- a/uri/UriInfo.php +++ b/uri/UriInfo.php @@ -13,6 +13,7 @@ namespace League\Uri; +use Deprecated; use League\Uri\Contracts\UriInterface; use Psr\Http\Message\UriInterface as Psr7UriInterface; @@ -33,6 +34,7 @@ private function __construct() /** * Tells whether the URI represents an absolute URI. */ + #[Deprecated(message:'use League\Uri\BaseUri::isAbsolute() instead', since:'league/uri:7.0.0')] public static function isAbsolute(Psr7UriInterface|UriInterface $uri): bool { return BaseUri::from($uri)->isAbsolute(); @@ -41,6 +43,7 @@ public static function isAbsolute(Psr7UriInterface|UriInterface $uri): bool /** * Tell whether the URI represents a network path. */ + #[Deprecated(message:'use League\Uri\BaseUri::isNetworkPath() instead', since:'league/uri:7.0.0')] public static function isNetworkPath(Psr7UriInterface|UriInterface $uri): bool { return BaseUri::from($uri)->isNetworkPath(); @@ -49,6 +52,7 @@ public static function isNetworkPath(Psr7UriInterface|UriInterface $uri): bool /** * Tells whether the URI represents an absolute path. */ + #[Deprecated(message:'use League\Uri\BaseUri::isAbsolutePath() instead', since:'league/uri:7.0.0')] public static function isAbsolutePath(Psr7UriInterface|UriInterface $uri): bool { return BaseUri::from($uri)->isAbsolutePath(); @@ -58,6 +62,7 @@ public static function isAbsolutePath(Psr7UriInterface|UriInterface $uri): bool * Tell whether the URI represents a relative path. * */ + #[Deprecated(message:'use League\Uri\BaseUri::isRelativePath() instead', since:'league/uri:7.0.0')] public static function isRelativePath(Psr7UriInterface|UriInterface $uri): bool { return BaseUri::from($uri)->isRelativePath(); @@ -66,6 +71,7 @@ public static function isRelativePath(Psr7UriInterface|UriInterface $uri): bool /** * Tells whether both URI refers to the same document. */ + #[Deprecated(message:'use League\Uri\BaseUri::isSameDocument() instead', since:'league/uri:7.0.0')] public static function isSameDocument(Psr7UriInterface|UriInterface $uri, Psr7UriInterface|UriInterface $baseUri): bool { return BaseUri::from($baseUri)->isSameDocument($uri); @@ -80,6 +86,7 @@ public static function isSameDocument(Psr7UriInterface|UriInterface $uri, Psr7Ur * For URI with the file scheme the method will return null (as this is left to the implementation decision) * For URI with a special scheme the method returns the scheme followed by its authority (without the userinfo part) */ + #[Deprecated(message:'use League\Uri\BaseUri::origin() instead', since:'league/uri:7.0.0')] public static function getOrigin(Psr7UriInterface|UriInterface $uri): ?string { return BaseUri::from($uri)->origin()?->__toString(); @@ -90,6 +97,7 @@ public static function getOrigin(Psr7UriInterface|UriInterface $uri): ?string * * @see UriInfo::getOrigin() */ + #[Deprecated(message:'use League\Uri\BaseUri::isCrossOrigin() instead', since:'league/uri:7.0.0')] public static function isCrossOrigin(Psr7UriInterface|UriInterface $uri, Psr7UriInterface|UriInterface $baseUri): bool { return BaseUri::from($baseUri)->isCrossOrigin($uri); diff --git a/uri/UriResolver.php b/uri/UriResolver.php index f1c9f7fc..a50966ad 100644 --- a/uri/UriResolver.php +++ b/uri/UriResolver.php @@ -13,6 +13,7 @@ namespace League\Uri; +use Deprecated; use League\Uri\Contracts\UriInterface; use Psr\Http\Message\UriInterface as Psr7UriInterface; @@ -32,6 +33,7 @@ final class UriResolver * This method MUST be transparent when dealing with error and exceptions. * It MUST not alter or silence them apart from validating its own parameters. */ + #[Deprecated(message:'use League\Uri\BaseUri::resolve() instead', since:'league/uri:7.0.0')] public static function resolve(Psr7UriInterface|UriInterface $uri, Psr7UriInterface|UriInterface $baseUri): Psr7UriInterface|UriInterface { return BaseUri::from($baseUri)->resolve($uri)->getUri(); @@ -46,6 +48,7 @@ public static function resolve(Psr7UriInterface|UriInterface $uri, Psr7UriInterf * This method MUST be transparent when dealing with error and exceptions. * It MUST not alter or silence them apart from validating its own parameters. */ + #[Deprecated(message:'use League\Uri\BaseUri::relativize() instead', since:'league/uri:7.0.0')] public static function relativize(Psr7UriInterface|UriInterface $uri, Psr7UriInterface|UriInterface $baseUri): Psr7UriInterface|UriInterface { return BaseUri::from($baseUri)->relativize($uri)->getUri(); diff --git a/uri/UriTemplate/Expression.php b/uri/UriTemplate/Expression.php index 350add69..d9d5b905 100644 --- a/uri/UriTemplate/Expression.php +++ b/uri/UriTemplate/Expression.php @@ -13,6 +13,7 @@ namespace League\Uri\UriTemplate; +use Deprecated; use League\Uri\Exceptions\SyntaxError; use Stringable; @@ -71,6 +72,7 @@ public static function new(Stringable|string $expression): self * @deprecated Since version 7.0.0 * @codeCoverageIgnore */ + #[Deprecated(message:'use League\Uri\UriTemplate\Exppression::new() instead', since:'league/uri:7.0.0')] public static function createFromString(Stringable|string $expression): self { return self::new($expression); diff --git a/uri/UriTemplate/Template.php b/uri/UriTemplate/Template.php index 60ea1e20..2727c948 100644 --- a/uri/UriTemplate/Template.php +++ b/uri/UriTemplate/Template.php @@ -13,6 +13,7 @@ namespace League\Uri\UriTemplate; +use Deprecated; use League\Uri\Exceptions\SyntaxError; use Stringable; @@ -136,6 +137,7 @@ public function __toString(): string * Create a new instance from a string. * */ + #[Deprecated(message:'use League\Uri\UriTemplate\Template::new() instead', since:'league/uri:7.0.0')] public static function createFromString(Stringable|string $template): self { return self::new($template);