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 eb091b8 commit c83f88b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace League\Uri;

use Deprecated;
use JsonSerializable;
use League\Uri\Contracts\UriException;
use League\Uri\Contracts\UriInterface;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
12 changes: 11 additions & 1 deletion Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace League\Uri;

use Deprecated;
use finfo;
use League\Uri\Contracts\UriComponentInterface;
use League\Uri\Contracts\UriException;
Expand Down Expand Up @@ -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<?string>
*/
private static function fetchRequestUri(array $server): array
{
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions UriInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace League\Uri;

use Deprecated;
use League\Uri\Contracts\UriInterface;
use Psr\Http\Message\UriInterface as Psr7UriInterface;

Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions UriResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace League\Uri;

use Deprecated;
use League\Uri\Contracts\UriInterface;
use Psr\Http\Message\UriInterface as Psr7UriInterface;

Expand All @@ -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();
Expand All @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions UriTemplate/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace League\Uri\UriTemplate;

use Deprecated;
use League\Uri\Exceptions\SyntaxError;
use Stringable;

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions UriTemplate/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace League\Uri\UriTemplate;

use Deprecated;
use League\Uri\Exceptions\SyntaxError;
use Stringable;

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c83f88b

Please sign in to comment.