Skip to content

fix: declare the key type of Collection::getIterator() for PHPStan 2.3 - #912

Closed
nfortier-shopware wants to merge 1 commit into
shyim:mainfrom
nfortier-shopware:fix/collection-iterator-key-type
Closed

nfortier-shopware wants to merge 1 commit into
shyim:mainfrom
nfortier-shopware:fix/collection-iterator-key-type

Conversation

@nfortier-shopware

Copy link
Copy Markdown
Contributor

CheckPhpStanTest::testValid fails on main since the CI install picks up PHPStan 2.3.1 (the lock file is not committed):

src/Struct/Collection.php:153: Return type (Generator<mixed, T, mixed, mixed>) of method Danger\Struct\Collection::getIterator() should be covariant with return type (Traversable<(int|string), mixed>) of method IteratorAggregate<(int|string),T>::getIterator()

@return \Generator<T> leaves the key type as mixed, which is wider than the array-key the IteratorAggregate<array-key, T> implementation promises. Declaring the key type fixes it.

@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.90%. Comparing base (4afecf4) to head (43ca487).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #912   +/-   ##
=========================================
  Coverage     98.90%   98.90%           
  Complexity      309      309           
=========================================
  Files            41       41           
  Lines           910      910           
=========================================
  Hits            900      900           
  Misses           10       10           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nfortier-shopware

Copy link
Copy Markdown
Contributor Author

Folded into #911, which carries this commit.

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.

1 participant