Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make nullable parameter types explicit #175

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Exception/HttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
$message,
RequestInterface $request,
ResponseInterface $response,
\Exception $previous = null
?\Exception $previous = null
) {
parent::__construct($message, $request, $previous);

Expand All @@ -50,7 +50,7 @@ public function getResponse()
public static function create(
RequestInterface $request,
ResponseInterface $response,
\Exception $previous = null
?\Exception $previous = null
) {
$message = sprintf(
'[url] %s [http method] %s [status code] %s [reason phrase] %s',
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/NetworkException.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class NetworkException extends TransferException implements PsrNetworkException
/**
* @param string $message
*/
public function __construct($message, RequestInterface $request, \Exception $previous = null)
public function __construct($message, RequestInterface $request, ?\Exception $previous = null)
{
$this->setRequest($request);

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/RequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RequestException extends TransferException implements PsrRequestException
/**
* @param string $message
*/
public function __construct($message, RequestInterface $request, \Exception $previous = null)
public function __construct($message, RequestInterface $request, ?\Exception $previous = null)
{
$this->setRequest($request);

Expand Down
2 changes: 1 addition & 1 deletion src/Promise/HttpFulfilledPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(ResponseInterface $response)
$this->response = $response;
}

public function then(callable $onFulfilled = null, callable $onRejected = null)
public function then(?callable $onFulfilled = null, ?callable $onRejected = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do this without the interface changing? if not, this bumps the minimum requirement of promise to the version that will contains php-http/promise#34

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do this without the interface changing?

Yes, this is a purely syntactical change.

{
if (null === $onFulfilled) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/Promise/HttpRejectedPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct(Exception $exception)
$this->exception = $exception;
}

public function then(callable $onFulfilled = null, callable $onRejected = null)
public function then(?callable $onFulfilled = null, ?callable $onRejected = null)
{
if (null === $onRejected) {
return $this;
Expand Down
Loading