Skip to content

Commit

Permalink
bot: fix cs [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Jan 16, 2024
1 parent 39fe887 commit 9004306
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Uri/Link/UriLinkProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getLinks(): iterable
public function getLinksByRel($rel): iterable
{
return \array_values(
\array_filter($this->links, static fn(UriLink $l) => \in_array($rel, $l->getRels(), true))
\array_filter($this->links, static fn(UriLink $l) => \in_array($rel, $l->getRels(), true)),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Uri/ParsedUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function authority(): Authority
new Host($this->parse()->parsed['host'] ?? null),
$this->parsed['user'] ?? null,
$this->parsed['pass'] ?? null,
$this->parsed['port'] ?? null
$this->parsed['port'] ?? null,
);
}

Expand Down
10 changes: 5 additions & 5 deletions src/Uri/Part/Authority.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class Authority extends Part
{
private string $string;

public function __construct(private Host $host, private ?string $username, private ?string $password, private ?int $port)
public function __construct(private Part\Host $host, private ?string $username, private ?string $password, private ?int $port)
{
}

Expand All @@ -31,21 +31,21 @@ public function __clone()
unset($this->string);
}

public function host(): Host
public function host(): Part\Host
{
return $this->host;
}

/**
* @return string|null "urldecoded"
* @return Part\string|null "urldecoded"
*/
public function username(): ?string

Check failure on line 42 in src/Uri/Part/Authority.php

View workflow job for this annotation

GitHub Actions / sca / Static Code Analysis

Method Zenstruck\Uri\Part\Authority::username() has invalid return type Zenstruck\Uri\Part\string.

Check failure on line 42 in src/Uri/Part/Authority.php

View workflow job for this annotation

GitHub Actions / sca / Static Code Analysis

PHPDoc tag @return with type Zenstruck\Uri\Part\string|null is not subtype of native type string|null.
{
return null !== $this->username ? \rawurldecode($this->username) : null;
}

/**
* @return string|null "urldecoded"
* @return Part\string|null "urldecoded"
*/
public function password(): ?string

Check failure on line 50 in src/Uri/Part/Authority.php

View workflow job for this annotation

GitHub Actions / sca / Static Code Analysis

Method Zenstruck\Uri\Part\Authority::password() has invalid return type Zenstruck\Uri\Part\string.

Check failure on line 50 in src/Uri/Part/Authority.php

View workflow job for this annotation

GitHub Actions / sca / Static Code Analysis

PHPDoc tag @return with type Zenstruck\Uri\Part\string|null is not subtype of native type string|null.
{
Expand Down Expand Up @@ -75,7 +75,7 @@ public function userInfo(): ?string
public function withHost(?string $host): self
{
$authority = clone $this;
$authority->host = new Host($host);
$authority->host = new Part\Host($host);

if ($authority->host->isEmpty()) {
$authority->username = null;
Expand Down
2 changes: 1 addition & 1 deletion src/Uri/Part/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function has(string $param): bool
*
* @param T|\Throwable $default
*
* @return T
* @return Part\T
*
* @throws \Throwable If passed as default and no match
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Uri/Signed/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class Builder implements \Stringable
private ?\DateTimeImmutable $expiresAt = null;
private ?string $singleUseToken = null;

public function __construct(private Uri $uri, private string|SymfonySigner $secret)
public function __construct(private Uri $uri, private string|Uri\Signed\SymfonySigner $secret)
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/Uri/SignedUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* @author Kevin Bond <[email protected]>
*/
final class SignedUri extends WrappedUri
final class SignedUri extends Uri\WrappedUri
{
private function __construct(private Uri $uri, private ?\DateTimeImmutable $expiresAt, private bool $singleUse)
{
Expand All @@ -32,7 +32,7 @@ public static function sign(string|Uri $uri, string|SymfonySigner $secret, ?\Dat
}

/**
* @param string|null $singleUseToken If passed, this value MUST change once the URL is considered "used"
* @param Uri\string|null $singleUseToken If passed, this value MUST change once the URL is considered "used"
*
* @throws Expired if the URI has expired
* @throws AlreadyUsed if the URI has already been used
Expand Down
18 changes: 9 additions & 9 deletions src/Uri/TemplateUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
*
* @immutable
*/
final class TemplateUri extends WrappedUri
final class TemplateUri extends Uri\WrappedUri
{
private UriTemplate $parser;
private Uri $uri;
private Parameters $parameters;
private Uri\Parameters $parameters;

private function __construct(private string $template)
{
Expand All @@ -35,9 +35,9 @@ private function __construct(private string $template)
/**
* @param array<string,mixed>|Parameters $parameters
*/
public static function expand(string $template, array|Parameters $parameters): self
public static function expand(string $template, array|Uri\Parameters $parameters): self
{
if ($parameters instanceof Parameters) {
if ($parameters instanceof Uri\Parameters) {
$parameters = $parameters->all();
}

Expand All @@ -50,7 +50,7 @@ public static function expand(string $template, array|Parameters $parameters): s
public static function extract(string $template, string|Uri $uri): self
{
$ret = new self($template);
$ret->uri = ParsedUri::wrap($uri);
$ret->uri = Uri\ParsedUri::wrap($uri);

return $ret;
}
Expand All @@ -60,7 +60,7 @@ public function template(): string
return $this->template;
}

public function parameters(): Parameters
public function parameters(): Uri\Parameters
{
return $this->parameters ??= self::filterParameters($this->parser()->extract($this->template, $this->uri) ?? throw new \LogicException());
}
Expand Down Expand Up @@ -106,15 +106,15 @@ public function mergeParameters(...$arrays): self

protected function inner(): Uri
{
return $this->uri ??= ParsedUri::wrap($this->parser()->expand($this->template, $this->parameters->all()));
return $this->uri ??= Uri\ParsedUri::wrap($this->parser()->expand($this->template, $this->parameters->all()));
}

/**
* @param mixed[] $values
*/
private static function filterParameters(array $values): Parameters
private static function filterParameters(array $values): Uri\Parameters
{
return new Parameters(\array_filter($values, static fn($v) => '' !== $v && null !== $v));
return new Uri\Parameters(\array_filter($values, static fn($v) => '' !== $v && null !== $v));
}

private function parser(): UriTemplate
Expand Down
2 changes: 1 addition & 1 deletion src/Uri/WrappedUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* @author Kevin Bond <[email protected]>
*/
abstract class WrappedUri extends BaseUri
abstract class WrappedUri extends Uri\BaseUri
{
final public function scheme(): Scheme
{
Expand Down
8 changes: 4 additions & 4 deletions tests/Link/UriLinkProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function decode(): void
'https://baz.com',
'https://qux.com',
],
\array_map(fn(UriLink $link) => $link->toString(), $links->getLinks())
\array_map(fn(UriLink $link) => $link->toString(), $links->getLinks()),
);

$this->assertSame(['next'], $links->getLinks()[1]->getRels());
Expand All @@ -138,7 +138,7 @@ public function countable_and_iterable(): void
'https://baz.com',
'https://qux.com',
],
\array_map(fn(UriLink $link) => $link->toString(), \iterator_to_array($links))
\array_map(fn(UriLink $link) => $link->toString(), \iterator_to_array($links)),
);
}

Expand All @@ -156,15 +156,15 @@ public function links_are_normalized(): void
'https://baz.com',
'https://qux.com',
],
\array_map(fn(UriLink $link) => $link->toString(), $links->getLinks())
\array_map(fn(UriLink $link) => $link->toString(), $links->getLinks()),
);
$this->assertSame(
[
'https://bar.com',
'https://baz.com',
'https://qux.com',
],
\array_map(fn(UriLink $link) => $link->toString(), $links->getLinksByRel('next'))
\array_map(fn(UriLink $link) => $link->toString(), $links->getLinksByRel('next')),
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/SignedUriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function can_access_expires_at(): void

$this->assertSame(
$expiresAt->getTimestamp(),
ParsedUri::wrap('/foo/bar')->sign('1234')->expires($expiresAt)->create()->expiresAt()?->getTimestamp()
ParsedUri::wrap('/foo/bar')->sign('1234')->expires($expiresAt)->create()->expiresAt()?->getTimestamp(),
);
}

Expand Down

0 comments on commit 9004306

Please sign in to comment.