From 35fa82d14c344784498172429496edde6cc3ec37 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 15 Mar 2024 13:30:17 +0100 Subject: [PATCH] Make nullable parameter types explicit --- CHANGELOG.md | 4 ++++ src/FulfilledPromise.php | 2 +- src/Promise.php | 2 +- src/RejectedPromise.php | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af1bac9..ff3bdd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 1.3.1 - unreleased + +- Made nullable parameter types explicit (PHP 8.4 compatibility) + ## 1.3.0 - 2024-01-04 ### Fixed diff --git a/src/FulfilledPromise.php b/src/FulfilledPromise.php index d934a37..ed77d46 100644 --- a/src/FulfilledPromise.php +++ b/src/FulfilledPromise.php @@ -22,7 +22,7 @@ public function __construct($result) $this->result = $result; } - public function then(callable $onFulfilled = null, callable $onRejected = null) + public function then(?callable $onFulfilled = null, ?callable $onRejected = null) { if (null === $onFulfilled) { return $this; diff --git a/src/Promise.php b/src/Promise.php index 35db1f7..e240311 100644 --- a/src/Promise.php +++ b/src/Promise.php @@ -41,7 +41,7 @@ interface Promise * * @return Promise a new resolved promise with value of the executed callback (onFulfilled / onRejected) */ - public function then(callable $onFulfilled = null, callable $onRejected = null); + public function then(?callable $onFulfilled = null, ?callable $onRejected = null); /** * Returns the state of the promise, one of PENDING, FULFILLED or REJECTED. diff --git a/src/RejectedPromise.php b/src/RejectedPromise.php index d6a0631..8c046ce 100644 --- a/src/RejectedPromise.php +++ b/src/RejectedPromise.php @@ -19,7 +19,7 @@ public function __construct(\Throwable $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;