From 5e0a90cbb6d3d36243641ee87aadde62ac12e34f Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 26 Jul 2024 13:43:20 +0545 Subject: [PATCH 1/6] chore: allow phpstan v1 --- .github/workflows/ci.yml | 5 ++++- composer.json | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f77d09..7804844 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,13 +14,16 @@ jobs: matrix: php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] coverage: ['pcov'] + code-style: ['no'] code-analysis: ['no'] include: - php-versions: '7.1' coverage: 'none' + code-style: 'yes' code-analysis: 'yes' - php-versions: '8.4' coverage: 'pcov' + code-style: 'no' code-analysis: 'yes' steps: - name: Checkout @@ -51,7 +54,7 @@ jobs: run: composer install --no-progress --prefer-dist --optimize-autoloader - name: Code Analysis (PHP CS-Fixer) - if: matrix.code-analysis == 'yes' + if: matrix.code-style == 'yes' run: PHP_CS_FIXER_IGNORE_ENV=true php vendor/bin/php-cs-fixer fix --dry-run --diff - name: Code Analysis (PHPStan) diff --git a/composer.json b/composer.json index 3c31181..fbcc03f 100644 --- a/composer.json +++ b/composer.json @@ -46,13 +46,14 @@ } }, "require-dev": { - "friendsofphp/php-cs-fixer": "~2.17.1", - "phpstan/phpstan": "^0.12", + "friendsofphp/php-cs-fixer": "~2.17.1 || ^3.60", + "phpstan/phpstan": "^0.12 || ^1.1", "phpunit/phpunit" : "^7.5 || ^8.5 || ^9.6" }, "scripts": { "phpstan": [ - "phpstan analyse lib tests" + "phpstan analyse lib", + "phpstan analyse tests" ], "cs-fixer": [ "php-cs-fixer fix" From 35d3afcea4541950f2ea055b568b1d4e7fcfe876 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 26 Jul 2024 16:50:01 +0545 Subject: [PATCH 2/6] chore: introduce a deprecated thing --- lib/Loop/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Loop/functions.php b/lib/Loop/functions.php index 9412a77..bf4d933 100644 --- a/lib/Loop/functions.php +++ b/lib/Loop/functions.php @@ -130,7 +130,7 @@ function stop() /** * Retrieves or sets the global Loop object. */ -function instance(?Loop $newLoop = null): Loop +function instance(Loop $newLoop = null): Loop { static $loop; if ($newLoop) { From 4b9cb4934883bb66748dfb9d8d47c042933e7bfe Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 26 Jul 2024 16:52:21 +0545 Subject: [PATCH 3/6] chore: introduce another deprecated thing --- lib/EmitterInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/EmitterInterface.php b/lib/EmitterInterface.php index 662efd7..9cf5bcd 100644 --- a/lib/EmitterInterface.php +++ b/lib/EmitterInterface.php @@ -74,5 +74,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); + public function removeAllListeners(string $eventName = null); } From 2f548bf9cbb535efedfc1444b64df6c0a61d1e0e Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 26 Jul 2024 16:54:09 +0545 Subject: [PATCH 4/6] chore: introduce another deprecated thing --- lib/EmitterTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/EmitterTrait.php b/lib/EmitterTrait.php index 5a0a234..cc1f55c 100644 --- a/lib/EmitterTrait.php +++ b/lib/EmitterTrait.php @@ -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) + public function removeAllListeners(string $eventName = null) { if (!\is_null($eventName)) { unset($this->listeners[$eventName]); From 618f17868a939681092883c1d1e1484dd70982ab Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 26 Jul 2024 17:03:49 +0545 Subject: [PATCH 5/6] chore: introduce more deprecated things --- lib/EmitterInterface.php | 2 +- lib/EmitterTrait.php | 2 +- lib/Promise.php | 6 +++--- lib/WildcardEmitterTrait.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/EmitterInterface.php b/lib/EmitterInterface.php index 9cf5bcd..6ce0f34 100644 --- a/lib/EmitterInterface.php +++ b/lib/EmitterInterface.php @@ -47,7 +47,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; /** * Returns the list of listeners for an event. diff --git a/lib/EmitterTrait.php b/lib/EmitterTrait.php index cc1f55c..5502ef9 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) { diff --git a/lib/Promise.php b/lib/Promise.php index 70921d0..b582126 100644 --- a/lib/Promise.php +++ b/lib/Promise.php @@ -58,7 +58,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 ($executor) { $executor( @@ -87,7 +87,7 @@ public function __construct(?callable $executor = null) * If either of the callbacks throw an exception, the returned promise will * be rejected and the exception will be passed back. */ - 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 @@ -220,7 +220,7 @@ public function wait() * correctly, and any chained promises are also correctly fulfilled or * rejected. */ - private function invokeCallback(Promise $subPromise, ?callable $callBack = null) + private function invokeCallback(Promise $subPromise, callable $callBack = null) { // 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 69243ff..206a8f3 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) + public function removeAllListeners(string $eventName = null) { if (\is_null($eventName)) { $this->listeners = []; From 467bfe35af09dcc2acaf2a4f722957892d3d3352 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 27 Aug 2024 15:22:27 +0545 Subject: [PATCH 6/6] chore: install extra components for phpstan v1 --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7804844..bd53147 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,15 +16,18 @@ jobs: coverage: ['pcov'] code-style: ['no'] code-analysis: ['no'] + code-analysis-extensions: ['no'] include: - php-versions: '7.1' coverage: 'none' code-style: 'yes' code-analysis: 'yes' + code-analysis-extensions: 'no' - php-versions: '8.4' coverage: 'pcov' code-style: 'no' code-analysis: 'yes' + code-analysis-extensions: 'yes' steps: - name: Checkout uses: actions/checkout@v4 @@ -53,6 +56,12 @@ jobs: - name: Install composer dependencies run: composer install --no-progress --prefer-dist --optimize-autoloader + - name: Extra components for phpstan v1 + if: matrix.code-analysis-extensions == 'yes' + run: | + composer config --no-plugins allow-plugins.phpstan/extension-installer true + composer require --dev phpstan/phpstan-phpunit phpstan/phpstan-strict-rules phpstan/extension-installer + - name: Code Analysis (PHP CS-Fixer) if: matrix.code-style == 'yes' run: PHP_CS_FIXER_IGNORE_ENV=true php vendor/bin/php-cs-fixer fix --dry-run --diff