diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4e8cc27..60d4f7a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -60,3 +60,18 @@ jobs: run: | wget https://scrutinizer-ci.com/ocular.phar php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml + + phpstan: + name: PHPStan + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: PHPStan + uses: OskarStark/phpstan-ga@0.12.32 + env: + REQUIRE_DEV: false + with: + args: analyze --no-progress diff --git a/CHANGELOG.md b/CHANGELOG.md index b57b33b..fafc207 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 1.2.1 + +### Added + +- Fixed PHPDoc for `wait()` and `then()`'s `onRejected` callable + ## 1.2.0 - 2023-10-24 ### Added diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..f8b94cf --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,6 @@ +parameters: + level: max + checkMissingIterableValueType: false + treatPhpDocTypesAsCertain: false + paths: + - src diff --git a/src/FulfilledPromise.php b/src/FulfilledPromise.php index dce0431..c9158e7 100644 --- a/src/FulfilledPromise.php +++ b/src/FulfilledPromise.php @@ -58,5 +58,7 @@ public function wait($unwrap = true) if ($unwrap) { return $this->result; } + + return; } } diff --git a/src/Promise.php b/src/Promise.php index 9383726..81434ae 100644 --- a/src/Promise.php +++ b/src/Promise.php @@ -39,7 +39,7 @@ interface Promise * The callback will be called when the value arrived and never more than once. * * @param callable(T): V|null $onFulfilled called when a response will be available - * @param callable(\Exception): V|null $onRejected called when an exception occurs + * @param callable(\Throwable): V|null $onRejected called when an exception occurs * * @return Promise a new resolved promise with value of the executed callback (onFulfilled / onRejected) * @@ -65,7 +65,7 @@ public function getState(); * * @param bool $unwrap Whether to return resolved value / throw reason or not * - * @return T Resolved value, null if $unwrap is set to false + * @return ($unwrap is true ? T : null) Resolved value, null if $unwrap is set to false * * @throws \Exception the rejection reason if $unwrap is set to true and the request failed */ diff --git a/src/RejectedPromise.php b/src/RejectedPromise.php index 2cbefec..a500048 100644 --- a/src/RejectedPromise.php +++ b/src/RejectedPromise.php @@ -55,5 +55,7 @@ public function wait($unwrap = true) if ($unwrap) { throw $this->exception; } + + return; } }