Skip to content

Commit

Permalink
explicitly mark nullable parameters as nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh authored and dunglas committed Mar 30, 2024
1 parent 8eb2496 commit 489282d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 24 deletions.
21 changes: 3 additions & 18 deletions src/Hub.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ final class Hub implements HubInterface
public function __construct(
string $url,
TokenProviderInterface $jwtProvider,
TokenFactoryInterface $jwtFactory = null,
string $publicUrl = null,
HttpClientInterface $httpClient = null
?TokenFactoryInterface $jwtFactory = null,
?string $publicUrl = null,
?HttpClientInterface $httpClient = null
) {
$this->url = $url;
$this->jwtProvider = $jwtProvider;
Expand All @@ -46,41 +46,26 @@ public function __construct(
$this->httpClient = $httpClient ?? HttpClient::create();
}

/**
* {@inheritDoc}
*/
public function getUrl(): string
{
return $this->url;
}

/**
* {@inheritDoc}
*/
public function getPublicUrl(): string
{
return $this->publicUrl ?? $this->getUrl();
}

/**
* {@inheritDoc}
*/
public function getProvider(): TokenProviderInterface
{
return $this->jwtProvider;
}

/**
* {@inheritDoc}
*/
public function getFactory(): ?TokenFactoryInterface
{
return $this->jwtFactory;
}

/**
* {@inheritDoc}
*/
public function publish(Update $update): string
{
$postData = [
Expand Down
2 changes: 1 addition & 1 deletion src/HubRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(HubInterface $defaultHub, array $hubs = [])
$this->hubs = $hubs;
}

public function getHub(string $name = null): HubInterface
public function getHub(?string $name = null): HubInterface
{
if (null === $name) {
return $this->defaultHub;
Expand Down
4 changes: 2 additions & 2 deletions src/MockHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function __construct(
string $url,
TokenProviderInterface $jwtProvider,
callable $publisher,
TokenFactoryInterface $jwtFactory = null,
string $publicUrl = null
?TokenFactoryInterface $jwtFactory = null,
?string $publicUrl = null
) {
$this->url = $url;
$this->jwtProvider = $jwtProvider;
Expand Down
2 changes: 1 addition & 1 deletion src/Publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final class Publisher implements PublisherInterface
/**
* @param TokenProviderInterface|callable(Update $update):string $jwtProvider
*/
public function __construct(string $hubUrl, $jwtProvider, HttpClientInterface $httpClient = null)
public function __construct(string $hubUrl, $jwtProvider, ?HttpClientInterface $httpClient = null)
{
$this->hubUrl = $hubUrl;
$this->jwtProvider = $jwtProvider;
Expand Down
2 changes: 1 addition & 1 deletion src/Twig/MercureExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class MercureExtension extends AbstractExtension
private $authorization;
private $requestStack;

public function __construct(HubRegistry $hubRegistry, Authorization $authorization = null, RequestStack $requestStack = null)
public function __construct(HubRegistry $hubRegistry, ?Authorization $authorization = null, ?RequestStack $requestStack = null)
{
$this->hubRegistry = $hubRegistry;
$this->authorization = $authorization;
Expand Down
2 changes: 1 addition & 1 deletion src/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class Update
/**
* @param string|string[] $topics
*/
public function __construct($topics, string $data = '', bool $private = false, string $id = null, string $type = null, int $retry = null)
public function __construct($topics, string $data = '', bool $private = false, ?string $id = null, ?string $type = null, ?int $retry = null)
{
if (!\is_array($topics) && !\is_string($topics)) {
throw new \InvalidArgumentException('$topics must be an array of strings or a string.');
Expand Down

0 comments on commit 489282d

Please sign in to comment.