Skip to content

Commit

Permalink
Improve internal codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Jun 6, 2024
1 parent eb54fa3 commit dd36cad
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
9 changes: 3 additions & 6 deletions interfaces/KeyValuePair/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,20 @@
final class Converter
{
private const REGEXP_INVALID_CHARS = '/[\x00-\x1f\x7f]/';
/** @var non-empty-string */
private readonly string $separator;

/**
* @param non-empty-string $separator the query string separator
* @param array<string> $fromRfc3986 contains all the RFC3986 encoded characters to be converted
* @param array<string> $toEncoding contains all the expected encoded characters
*/
private function __construct(
string $separator,
private readonly string $separator,
private readonly array $fromRfc3986 = [],
private readonly array $toEncoding = [],
) {
if ('' === $separator) {
if ('' === $this->separator) {
throw new SyntaxError('The separator character must be a non empty string.');
}

$this->separator = $separator;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions interfaces/UriString.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ final class UriString
/**
* Simple URI which do not need any parsing.
*/
private const URI_SCHORTCUTS = [
private const URI_SHORTCUTS = [
'' => [],
'#' => ['fragment' => ''],
'?' => ['query' => ''],
Expand Down Expand Up @@ -85,7 +85,7 @@ final class UriString
,x';

/**
* URI scheme regular expresssion.
* URI scheme regular expression.
*
* @link https://tools.ietf.org/html/rfc3986#section-3.1
*/
Expand Down Expand Up @@ -258,9 +258,9 @@ public static function buildAuthority(array $components): ?string
public static function parse(Stringable|string|int $uri): array
{
$uri = (string) $uri;
if (isset(self::URI_SCHORTCUTS[$uri])) {
if (isset(self::URI_SHORTCUTS[$uri])) {
/** @var ComponentMap $components */
$components = array_merge(self::URI_COMPONENTS, self::URI_SCHORTCUTS[$uri]);
$components = array_merge(self::URI_COMPONENTS, self::URI_SHORTCUTS[$uri]);

return $components;
}
Expand Down
2 changes: 1 addition & 1 deletion uri/BaseUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public function resolve(Stringable|string $uri): static
->withQuery($query)
->withHost($this->uri->getHost())
->withPort($this->uri->getPort())
->withUserInfo((string) $user, $pass)
->withUserInfo($user, $pass)
->withScheme($this->uri->getScheme()),
$this->uriFactory
);
Expand Down
2 changes: 1 addition & 1 deletion uri/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ private function formatPort(?int $port = null): ?int
/**
* Create a new instance from a string.
*/
public static function new(Stringable|string $uri = ''): self
public static function new(#[SensitiveParameter] Stringable|string $uri = ''): self
{
$components = match (true) {
$uri instanceof UriInterface => $uri->getComponents(),
Expand Down

0 comments on commit dd36cad

Please sign in to comment.