Skip to content

Update PHPStan and fix type annotations #267

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

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"php": ">=7.1.0"
},
"require-dev": {
"phpstan/phpstan": "1.10.39 || 1.4.10",
"phpstan/phpstan": "1.12.19 || 1.4.10",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PaulRotmann This is quite old, are you sure we don't want to go to 1.12.28 at least?

"phpunit/phpunit": "^9.6 || ^7.5"
},
"autoload": {
Expand Down
5 changes: 5 additions & 0 deletions src/Internal/FulfilledPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ public function catch(callable $onRejected): PromiseInterface
return $this;
}

/**
* @param callable(): (void|PromiseInterface<void>) $onFulfilledOrRejected
* @return PromiseInterface<T>
*/
Comment on lines +59 to +62
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this locally and this doesn't appear to be needed, as its types would be inherited directly from the PromiseInterface:

Suggested change
/**
* @param callable(): (void|PromiseInterface<void>) $onFulfilledOrRejected
* @return PromiseInterface<T>
*/

May I ask you do confirm?

public function finally(callable $onFulfilledOrRejected): PromiseInterface
{
return $this->then(function ($value) use ($onFulfilledOrRejected): PromiseInterface {
/** @var T $value */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Mixed whitespace, should use spaces only

Suggested change
/** @var T $value */
/** @var T $value */

return resolve($onFulfilledOrRejected())->then(function () use ($value) {
return $value;
});
Expand Down
5 changes: 5 additions & 0 deletions src/Promise.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,14 @@ public function catch(callable $onRejected): PromiseInterface
});
}

/**
* @param callable(): (void|PromiseInterface<void>) $onFulfilledOrRejected
* @return PromiseInterface<T>
*/
Comment on lines +97 to +100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this locally and this doesn't appear to be needed, as its types would be inherited directly from the PromiseInterface:

Suggested change
/**
* @param callable(): (void|PromiseInterface<void>) $onFulfilledOrRejected
* @return PromiseInterface<T>
*/

May I ask you do confirm?

public function finally(callable $onFulfilledOrRejected): PromiseInterface
{
return $this->then(static function ($value) use ($onFulfilledOrRejected): PromiseInterface {
/** @var T $value */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Mixed whitespace, should use spaces only

Suggested change
/** @var T $value */
/** @var T $value */

return resolve($onFulfilledOrRejected())->then(function () use ($value) {
return $value;
});
Expand Down