From 24fb8f146b766d491231c6406eceb01071172870 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 11 Feb 2024 12:43:09 +0545 Subject: [PATCH 1/2] chore: use php-cs-fixer 3.49 --- composer.json | 2 +- lib/EmitterInterface.php | 4 ++-- lib/EmitterTrait.php | 6 +++--- lib/Loop/Loop.php | 4 ++-- lib/Loop/functions.php | 6 +++--- lib/Promise.php | 6 +++--- lib/WildcardEmitterTrait.php | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index f69c788..b1b2e14 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ } }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.38", + "friendsofphp/php-cs-fixer": "^3.49", "phpstan/phpstan": "^1.10", "phpstan/phpstan-phpunit": "^1.3", "phpstan/phpstan-strict-rules": "^1.5", diff --git a/lib/EmitterInterface.php b/lib/EmitterInterface.php index 05b0513..b91f5fd 100644 --- a/lib/EmitterInterface.php +++ b/lib/EmitterInterface.php @@ -50,7 +50,7 @@ public function once(string $eventName, callable $callBack, int $priority = 100) * @param list $arguments * @param callable():bool|null $continueCallBack */ - public function emit(string $eventName, array $arguments = [], callable $continueCallBack = null): bool; + public function emit(string $eventName, array $arguments = [], ?callable $continueCallBack = null): bool; /** * Returns the list of listeners for an event. @@ -77,5 +77,5 @@ public function removeListener(string $eventName, callable $listener): bool; * removed. If it is not specified, every listener for every event is * removed. */ - public function removeAllListeners(string $eventName = null): void; + public function removeAllListeners(?string $eventName = null): void; } diff --git a/lib/EmitterTrait.php b/lib/EmitterTrait.php index a53a7a9..70a2aa1 100644 --- a/lib/EmitterTrait.php +++ b/lib/EmitterTrait.php @@ -73,7 +73,7 @@ public function once(string $eventName, callable $callBack, int $priority = 100) * Lastly, if there are 5 event handlers for an event. The continueCallback * will be called at most 4 times. */ - public function emit(string $eventName, array $arguments = [], callable $continueCallBack = null): bool + public function emit(string $eventName, array $arguments = [], ?callable $continueCallBack = null): bool { if (\is_null($continueCallBack)) { foreach ($this->listeners($eventName) as $listener) { @@ -160,7 +160,7 @@ public function removeListener(string $eventName, callable $listener): bool * removed. If it is not specified, every listener for every event is * removed. */ - public function removeAllListeners(string $eventName = null): void + public function removeAllListeners(?string $eventName = null): void { if (!\is_null($eventName)) { unset($this->listeners[$eventName]); @@ -172,7 +172,7 @@ public function removeAllListeners(string $eventName = null): void /** * The list of listeners. * - * @var array, 2:list}> + * @var array, 2:list}> */ protected array $listeners = []; } diff --git a/lib/Loop/Loop.php b/lib/Loop/Loop.php index 5b45ce1..4a96e11 100644 --- a/lib/Loop/Loop.php +++ b/lib/Loop/Loop.php @@ -61,7 +61,7 @@ public function setTimeout(callable $cb, float $timeout): void * The value this function returns can be used to stop the interval with * clearInterval. * - * @return array{0:string, 1:boolean} + * @return array{0:string, 1:bool} */ public function setInterval(callable $cb, float $timeout): array { @@ -88,7 +88,7 @@ public function setInterval(callable $cb, float $timeout): array /** * Stops a running interval. * - * @param array{0:string, 1:boolean} $intervalId + * @param array{0:string, 1:bool} $intervalId */ public function clearInterval(array $intervalId): void { diff --git a/lib/Loop/functions.php b/lib/Loop/functions.php index 6723222..00d4ce5 100644 --- a/lib/Loop/functions.php +++ b/lib/Loop/functions.php @@ -18,7 +18,7 @@ function setTimeout(callable $cb, float $timeout): void * The value this function returns can be used to stop the interval with * clearInterval. * - * @return array{0:string, 1:boolean} + * @return array{0:string, 1:bool} */ function setInterval(callable $cb, float $timeout): array { @@ -28,7 +28,7 @@ function setInterval(callable $cb, float $timeout): array /** * Stops a running interval. * - * @param array{0:string, 1:boolean} $intervalId + * @param array{0:string, 1:bool} $intervalId */ function clearInterval(array $intervalId): void { @@ -134,7 +134,7 @@ function stop(): void /** * Retrieves or sets the global Loop object. */ -function instance(Loop $newLoop = null): Loop +function instance(?Loop $newLoop = null): Loop { static $loop; if ($newLoop instanceof Loop) { diff --git a/lib/Promise.php b/lib/Promise.php index 5d6e3b1..2567840 100644 --- a/lib/Promise.php +++ b/lib/Promise.php @@ -53,7 +53,7 @@ class Promise * Each are callbacks that map to $this->fulfill and $this->reject. * Using the executor is optional. */ - public function __construct(callable $executor = null) + public function __construct(?callable $executor = null) { if (is_callable($executor)) { $executor( @@ -84,7 +84,7 @@ public function __construct(callable $executor = null) * * @return Promise */ - public function then(callable $onFulfilled = null, callable $onRejected = null): Promise + public function then(?callable $onFulfilled = null, ?callable $onRejected = null): Promise { // This new subPromise will be returned from this function, and will // be fulfilled with the result of the onFulfilled or onRejected event @@ -225,7 +225,7 @@ public function wait() * * @param Promise $subPromise */ - private function invokeCallback(Promise $subPromise, callable $callBack = null): void + private function invokeCallback(Promise $subPromise, ?callable $callBack = null): void { // We use 'nextTick' to ensure that the event handlers are always // triggered outside of the calling stack in which they were originally diff --git a/lib/WildcardEmitterTrait.php b/lib/WildcardEmitterTrait.php index 1a4c69c..f1af244 100644 --- a/lib/WildcardEmitterTrait.php +++ b/lib/WildcardEmitterTrait.php @@ -82,7 +82,7 @@ public function once(string $eventName, callable $callBack, int $priority = 100) * Lastly, if there are 5 event handlers for an event. The continueCallback * will be called at most 4 times. */ - public function emit(string $eventName, array $arguments = [], callable $continueCallBack = null): bool + public function emit(string $eventName, array $arguments = [], ?callable $continueCallBack = null): bool { if (\is_null($continueCallBack)) { foreach ($this->listeners($eventName) as $listener) { @@ -195,7 +195,7 @@ public function removeListener(string $eventName, callable $listener): bool * removed. If it is not specified, every listener for every event is * removed. */ - public function removeAllListeners(string $eventName = null): void + public function removeAllListeners(?string $eventName = null): void { if (\is_null($eventName)) { $this->listeners = []; From 45fe5fd2c72b3577deda9598d83a0e7c4384a140 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 4 Mar 2024 11:29:42 +0545 Subject: [PATCH 2/2] chore: use php-cs-fixer 3.51 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b1b2e14..7aed193 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ } }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.49", + "friendsofphp/php-cs-fixer": "^3.51", "phpstan/phpstan": "^1.10", "phpstan/phpstan-phpunit": "^1.3", "phpstan/phpstan-strict-rules": "^1.5",