Skip to content

Make ArrayHash stub generic - #225

Merged
ondrejmirtes merged 2 commits into
2.0.xfrom
generic-array-hash-stub
Oct 11, 2026
Merged

ondrejmirtes merged 2 commits into
2.0.xfrom
generic-array-hash-stub

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

The ArrayHash stub now follows the PHPDoc of Nette\Utils\ArrayHash in nette/utils 4.x:

  • @template T, with @implements \IteratorAggregate<array-key, T> and @implements \ArrayAccess<array-key, T>
  • extends \stdClass (cosmetic, the real class extends it too)
  • getIterator() returns \Iterator<array-key, T>

Previously the stub made ArrayHash non-generic, so types like ArrayHash<mixed> from the nette/forms 3.2.9+ PHPDoc, or ArrayHash<int> written by users, were collapsed into plain ArrayHash.

Nette\Utils\ArrayHash is added to skipCheckGenericClasses, so ArrayHash without a type argument is not reported with missingType.generics. Bleeding edge empties this list (skipCheckGenericClasses!: []), so projects using it will see these errors, as with other generic classes.

@property ArrayHash $values in the Container stub is now ArrayHash<mixed>.

On nette/utils 2.x and 3.x, getIterator() is natively declared as \RecursiveArrayIterator, so PHPStan uses the native return type there and foreach over ArrayHash keeps giving mixed values, as before. The iterator test only runs on nette/utils 4.0+.

🤖 Generated with Claude Code

ondrejmirtes and others added 2 commits October 11, 2026 18:05
The ArrayHash stub now follows the PHPDoc of nette/utils: ArrayHash is
generic over its values and extends stdClass. Generic types like
ArrayHash<mixed> from nette/forms 3.2.9+ PHPDoc are no longer collapsed
into non-generic ArrayHash.

ArrayHash is added to skipCheckGenericClasses so that ArrayHash without
a type argument is not reported as missing its generic types.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ondrejmirtes
ondrejmirtes merged commit a524f3d into 2.0.x Oct 11, 2026
45 checks passed
@ondrejmirtes
ondrejmirtes deleted the generic-array-hash-stub branch October 11, 2026 16:09
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