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

Add PHP 8.4 to the CI and fix implicit nullable types #259

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
strategy:
matrix:
php:
- 8.4
- 8.3
- 8.2
- 8.1
Expand All @@ -26,6 +27,8 @@ jobs:
php-version: ${{ matrix.php }}
coverage: xdebug
ini-file: development
- run: composer config minimum-stability dev
if: ${{ matrix.php >= 8.4 }}
- run: composer install
- run: vendor/bin/phpunit --coverage-text
if: ${{ matrix.php >= 7.3 }}
Expand Down
2 changes: 1 addition & 1 deletion src/Deferred.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class Deferred
/**
* @param (callable(callable(T):void,callable(\Throwable):void):void)|null $canceller
*/
public function __construct(callable $canceller = null)
public function __construct(?callable $canceller = null)
{
$this->promise = new Promise(function ($resolve, $reject): void {
$this->resolveCallback = $resolve;
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/FulfilledPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct($value = null)
* @param ?(callable((T is void ? null : T)): (PromiseInterface<TFulfilled>|TFulfilled)) $onFulfilled
* @return PromiseInterface<($onFulfilled is null ? T : TFulfilled)>
*/
public function then(callable $onFulfilled = null, callable $onRejected = null): PromiseInterface
public function then(?callable $onFulfilled = null, ?callable $onRejected = null): PromiseInterface
{
if (null === $onFulfilled) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/RejectedPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __destruct()
* @param ?(callable(\Throwable): (PromiseInterface<TRejected>|TRejected)) $onRejected
* @return PromiseInterface<($onRejected is null ? never : TRejected)>
*/
public function then(callable $onFulfilled = null, callable $onRejected = null): PromiseInterface
public function then(?callable $onFulfilled = null, ?callable $onRejected = null): PromiseInterface
{
if (null === $onRejected) {
return $this;
Expand Down
6 changes: 3 additions & 3 deletions src/Promise.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class Promise implements PromiseInterface
* @param callable(callable(T):void,callable(\Throwable):void):void $resolver
* @param (callable(callable(T):void,callable(\Throwable):void):void)|null $canceller
*/
public function __construct(callable $resolver, callable $canceller = null)
public function __construct(callable $resolver, ?callable $canceller = null)
{
$this->canceller = $canceller;

Expand All @@ -41,7 +41,7 @@ public function __construct(callable $resolver, callable $canceller = null)
$this->call($cb);
}

public function then(callable $onFulfilled = null, callable $onRejected = null): PromiseInterface
public function then(?callable $onFulfilled = null, ?callable $onRejected = null): PromiseInterface
{
if (null !== $this->result) {
return $this->result->then($onFulfilled, $onRejected);
Expand Down Expand Up @@ -166,7 +166,7 @@ public function always(callable $onFulfilledOrRejected): PromiseInterface
return $this->finally($onFulfilledOrRejected);
}

private function resolver(callable $onFulfilled = null, callable $onRejected = null): callable
private function resolver(?callable $onFulfilled = null, ?callable $onRejected = null): callable
{
return function (callable $resolve, callable $reject) use ($onFulfilled, $onRejected): void {
$this->handlers[] = static function (PromiseInterface $promise) use ($onFulfilled, $onRejected, $resolve, $reject): void {
Expand Down
2 changes: 1 addition & 1 deletion tests/DeferredTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DeferredTest extends TestCase
/**
* @return CallbackPromiseAdapter<T>
*/
public function getPromiseTestAdapter(callable $canceller = null): CallbackPromiseAdapter
public function getPromiseTestAdapter(?callable $canceller = null): CallbackPromiseAdapter
{
$d = new Deferred($canceller);

Expand Down
2 changes: 1 addition & 1 deletion tests/Internal/FulfilledPromiseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FulfilledPromiseTest extends TestCase
/**
* @return CallbackPromiseAdapter<T>
*/
public function getPromiseTestAdapter(callable $canceller = null): CallbackPromiseAdapter
public function getPromiseTestAdapter(?callable $canceller = null): CallbackPromiseAdapter
{
/** @var ?FulfilledPromise<T> */
$promise = null;
Expand Down
2 changes: 1 addition & 1 deletion tests/Internal/RejectedPromiseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RejectedPromiseTest extends TestCase
/**
* @return CallbackPromiseAdapter<never>
*/
public function getPromiseTestAdapter(callable $canceller = null): CallbackPromiseAdapter
public function getPromiseTestAdapter(?callable $canceller = null): CallbackPromiseAdapter
{
/** @var ?RejectedPromise */
$promise = null;
Expand Down
2 changes: 1 addition & 1 deletion tests/PromiseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PromiseTest extends TestCase
/**
* @return CallbackPromiseAdapter<T>
*/
public function getPromiseTestAdapter(callable $canceller = null): CallbackPromiseAdapter
public function getPromiseTestAdapter(?callable $canceller = null): CallbackPromiseAdapter
{
$resolveCallback = $rejectCallback = null;

Expand Down
2 changes: 1 addition & 1 deletion tests/PromiseTest/CancelTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

trait CancelTestTrait
{
abstract public function getPromiseTestAdapter(callable $canceller = null): PromiseAdapterInterface;
abstract public function getPromiseTestAdapter(?callable $canceller = null): PromiseAdapterInterface;

/** @test */
public function cancelShouldCallCancellerWithResolverArguments(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/PromiseTest/PromiseFulfilledTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

trait PromiseFulfilledTestTrait
{
abstract public function getPromiseTestAdapter(callable $canceller = null): PromiseAdapterInterface;
abstract public function getPromiseTestAdapter(?callable $canceller = null): PromiseAdapterInterface;

/** @test */
public function fulfilledPromiseShouldBeImmutable(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/PromiseTest/PromisePendingTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

trait PromisePendingTestTrait
{
abstract public function getPromiseTestAdapter(callable $canceller = null): PromiseAdapterInterface;
abstract public function getPromiseTestAdapter(?callable $canceller = null): PromiseAdapterInterface;

/** @test */
public function thenShouldReturnAPromiseForPendingPromise(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/PromiseTest/PromiseRejectedTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

trait PromiseRejectedTestTrait
{
abstract public function getPromiseTestAdapter(callable $canceller = null): PromiseAdapterInterface;
abstract public function getPromiseTestAdapter(?callable $canceller = null): PromiseAdapterInterface;

/** @test */
public function rejectedPromiseShouldBeImmutable(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/PromiseTest/PromiseSettledTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

trait PromiseSettledTestTrait
{
abstract public function getPromiseTestAdapter(callable $canceller = null): PromiseAdapterInterface;
abstract public function getPromiseTestAdapter(?callable $canceller = null): PromiseAdapterInterface;

/** @test */
public function thenShouldReturnAPromiseForSettledPromise(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/PromiseTest/RejectTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

trait RejectTestTrait
{
abstract public function getPromiseTestAdapter(callable $canceller = null): PromiseAdapterInterface;
abstract public function getPromiseTestAdapter(?callable $canceller = null): PromiseAdapterInterface;

/** @test */
public function rejectShouldRejectWithAnException(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/PromiseTest/ResolveTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

trait ResolveTestTrait
{
abstract public function getPromiseTestAdapter(callable $canceller = null): PromiseAdapterInterface;
abstract public function getPromiseTestAdapter(?callable $canceller = null): PromiseAdapterInterface;

/** @test */
public function resolveShouldResolve(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/SimpleFulfilledTestThenable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class SimpleFulfilledTestThenable
{
public function then(callable $onFulfilled = null, callable $onRejected = null): self
public function then(?callable $onFulfilled = null, ?callable $onRejected = null): self
{
if ($onFulfilled) {
$onFulfilled('foo');
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/SimpleTestCancellableThenable.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ class SimpleTestCancellableThenable
/** @var ?callable */
public $onCancel;

public function __construct(callable $onCancel = null)
public function __construct(?callable $onCancel = null)
{
$this->onCancel = $onCancel;
}

public function then(callable $onFulfilled = null, callable $onRejected = null): self
public function then(?callable $onFulfilled = null, ?callable $onRejected = null): self
{
return new self();
}
Expand Down