Skip to content

Commit

Permalink
Uri::getUsername is an alias for Uri::getUser
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Jan 5, 2025
1 parent cbcc0b6 commit f0e42ea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
3 changes: 2 additions & 1 deletion interfaces/Idna/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use function idn_to_ascii;
use function idn_to_utf8;
use function rawurldecode;
use function strtolower;

use const INTL_IDNA_VARIANT_UTS46;

Expand Down Expand Up @@ -155,7 +156,7 @@ public static function toUnicode(Stringable|string $domain, Option|int|null $opt
idn_to_utf8($domain, $flags->toBytes(), INTL_IDNA_VARIANT_UTS46, $idnaInfo);

if ([] === $idnaInfo) {
return Result::fromIntl(['result' => $domain, 'isTransitionalDifferent' => false, 'errors' => Error::NONE->value]);
return Result::fromIntl(['result' => strtolower($domain), 'isTransitionalDifferent' => false, 'errors' => Error::NONE->value]);
}

return Result::fromIntl($idnaInfo);
Expand Down
1 change: 1 addition & 0 deletions uri/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ All Notable changes to `League\Uri` will be documented in this file
- `Uri::when` conditional method to ease component building logic.
- `Uri` implements the new `League\Uri\Contract\UriInspector` interface
- `Uri` implements the new `League\Uri\Contract\UriRenderer` interface
- `Uri::getUser` returns the encoded user component of the URI an alias for `Uri::getUsername`

### Fixed

Expand Down
30 changes: 14 additions & 16 deletions uri/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -1322,13 +1322,26 @@ public function getAuthority(): ?string
}

/**
* * @see https://wiki.php.net/rfc/url_parsing_api
* Returns the user component encoded value.
*
* @see https://wiki.php.net/rfc/url_parsing_api
*/
public function getUser(): ?string
{
return $this->user;
}

/**
* Returns the user component encoded value.
*
* @codeCoverageIgnore
* @see Uri::getUser()
*/
public function getUsername(): ?string
{
return $this->getUser();
}

public function getPassword(): ?string
{
return $this->pass;
Expand Down Expand Up @@ -1964,19 +1977,4 @@ public static function createFromServer(array $server): self
{
return self::fromServer($server);
}

/**
* DEPRECATION WARNING! This method will be removed in the next major point release.
*
* @deprecated Since version 7.6.0
* @codeCoverageIgnore
* @see Uri::getUser()
*
* Retuns the user component encoded value.
*/
#[Deprecated(message:'use League\Uri\Uri::getUser() instead', since:'league/uri:7.6.0')]
public function getUsername(): ?string
{
return $this->getUser();
}
}

0 comments on commit f0e42ea

Please sign in to comment.