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

Conversation

PaulRotmann
Copy link

@PaulRotmann PaulRotmann commented Aug 6, 2025

The updated PHPStan version provides improved type checking capabilities. The added type annotations resolve static analysis warnings and improve code documentation, making the generic type flow more explicit in the finally() method implementations.

Builds on top of #251.

This PR breaks down #266 into smaller parts.

Copy link
Member

@clue clue left a comment

Choose a reason for hiding this comment

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

@PaulRotmann Thanks for looking into this, updating PHPStan sounds good. I've added some remarks below.

Comment on lines +59 to +62
/**
* @param callable(): (void|PromiseInterface<void>) $onFulfilledOrRejected
* @return PromiseInterface<T>
*/
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?

Comment on lines +97 to +100
/**
* @param callable(): (void|PromiseInterface<void>) $onFulfilledOrRejected
* @return PromiseInterface<T>
*/
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 */

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 */

@@ -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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants