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 implicit nullable types explicit #431

Merged
merged 1 commit into from
Mar 21, 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
2 changes: 1 addition & 1 deletion lib/CancellationTokenSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function getToken(): CancellationToken
*
* @return void
*/
public function cancel(\Throwable $previous = null)
public function cancel(?\Throwable $previous = null)
{
if ($this->onCancel === null) {
return;
Expand Down
2 changes: 1 addition & 1 deletion lib/CancelledException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class CancelledException extends \Exception
{
public function __construct(\Throwable $previous = null)
public function __construct(?\Throwable $previous = null)
{
parent::__construct("The operation was cancelled", 0, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Coroutine.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function __construct(\Generator $generator)
* @psalm-suppress MissingClosureParamType
* @psalm-suppress MissingClosureReturnType
*/
$onResolve = function (\Throwable $e = null, $v) use ($generator, &$onResolve) {
$onResolve = function (?\Throwable $e = null, $v) use ($generator, &$onResolve) {
/** @var bool $immediate Used to control iterative coroutine continuation. */
static $immediate = true;

Expand Down
2 changes: 1 addition & 1 deletion lib/Internal/ResolutionQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ResolutionQueue
* Promise|\React\Promise\PromiseInterface|array<array-key, Promise|\React\Promise\PromiseInterface>, mixed,
* mixed>|null) | callable(\Throwable|null, mixed): void $callback
*/
public function __construct(callable $callback = null)
public function __construct(?callable $callback = null)
{
if ($callback !== null) {
$this->push($callback);
Expand Down
2 changes: 1 addition & 1 deletion lib/InvalidYieldError.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class InvalidYieldError extends \Error
* @param string $prefix
* @param \Throwable|null $previous
*/
public function __construct(\Generator $generator, string $prefix, \Throwable $previous = null)
public function __construct(\Generator $generator, string $prefix, ?\Throwable $previous = null)
{
$yielded = $generator->current();
$prefix .= \sprintf(
Expand Down
4 changes: 2 additions & 2 deletions lib/Loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function getHandle()
*
* @return void
*/
public static function run(callable $callback = null)
public static function run(?callable $callback = null)
{
if ($callback) {
self::$driver->defer($callback);
Expand Down Expand Up @@ -406,7 +406,7 @@ public static function getState(string $key)
*
* @return callable(\Throwable $error)|null The previous handler, `null` if there was none.
*/
public static function setErrorHandler(callable $callback = null)
public static function setErrorHandler(?callable $callback = null)
{
return self::$driver->setErrorHandler($callback);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Loop/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ final public function getState(string $key)
*
* @return callable(\Throwable $error):void|null The previous handler, `null` if there was none.
*/
public function setErrorHandler(callable $callback = null)
public function setErrorHandler(?callable $callback = null)
{
$previous = $this->errorHandler;
$this->errorHandler = $callback;
Expand Down
2 changes: 1 addition & 1 deletion lib/Loop/TracingDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function unreference(string $watcherId)
$this->unreferencedWatchers[$watcherId] = true;
}

public function setErrorHandler(callable $callback = null)
public function setErrorHandler(?callable $callback = null)
{
return $this->driver->setErrorHandler($callback);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/MultiReasonException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class MultiReasonException extends \Exception
* @param \Throwable[] $reasons Array of exceptions rejecting the promise.
* @param string|null $message
*/
public function __construct(array $reasons, string $message = null)
public function __construct(array $reasons, ?string $message = null)
{
parent::__construct($message ?: "Multiple errors encountered; use "
. self::class . "::getReasons() to retrieve the array of exceptions thrown");
Expand Down
2 changes: 1 addition & 1 deletion lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ function wrap($promise, callable $callback): Promise

$deferred = new Deferred();

$promise->onResolve(static function (\Throwable $exception = null, $result) use ($deferred, $callback) {
$promise->onResolve(static function (?\Throwable $exception = null, $result) use ($deferred, $callback) {
try {
$result = $callback($exception, $result);
} catch (\Throwable $exception) {
Expand Down
Loading