Skip to content

feat: update phpstan 2.0 #11

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

Merged
merged 4 commits into from
Feb 21, 2025
Merged

feat: update phpstan 2.0 #11

merged 4 commits into from
Feb 21, 2025

Conversation

edodusi
Copy link
Contributor

@edodusi edodusi commented Feb 19, 2025

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Feb 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.20%. Comparing base (c92407e) to head (a9e13b6).

Additional details and impacted files
@@            Coverage Diff            @@
##             master      #11   +/-   ##
=========================================
  Coverage     92.20%   92.20%           
  Complexity       52       52           
=========================================
  Files             7        7           
  Lines           231      231           
=========================================
  Hits            213      213           
  Misses           18       18           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -24,7 +24,7 @@
final readonly class WebhookEventHandlerChain
{
/**
* @var list<WebhookHandlerInterface>
* @var array<WebhookHandlerInterface>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* @var array<WebhookHandlerInterface>
* @var list<WebhookHandlerInterface>

Lets keep this and add it to the baseline instead.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually i think WebhookHandlerInterface[] is already implying its a list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can you help me understand why we need to keep list and add it to baseline? Is this an issue with phpstan?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like a false positive to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but iterator_to_array could actually preserve the keys of the $handlers array, so list I think is inaccurate in this case.

We can solve this if we explicitly don't preserve the keys:

$this->handlers = iterator_to_array($handlers, false);

What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We know 100% that there is a list coming with numeric ascending keys. So list is still the right type here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@silasjoisten ok so if we set preserve_keys to false it should be valid, and this would also make the annotation valid and phpstan happy

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's do it

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please also release a 0.3 afterwards? Many thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

@edodusi
Copy link
Contributor Author

edodusi commented Feb 21, 2025

@OskarStark @silasjoisten can you please have a look at the new diff, I changed both the constructor body and the getHandlers to have list type

@edodusi edodusi requested a review from OskarStark February 21, 2025 08:43
@OskarStark
Copy link
Collaborator

Looks good to me, but can you use a bed argument for the false argument? Thanks

@edodusi edodusi merged commit 080b82f into master Feb 21, 2025
3 checks passed
@edodusi edodusi deleted the chore/update-phpstan branch February 21, 2025 08:53
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.

4 participants