Skip to content

fix(types): disambiguate array return types in form containers - #358

Open
ondraondra81 wants to merge 1 commit into
nette:masterfrom
ondraondra81:fix/container-array-return-types
Open

ondraondra81 wants to merge 1 commit into
nette:masterfrom
ondraondra81:fix/container-array-return-types

Conversation

@ondraondra81

@ondraondra81 ondraondra81 commented Nov 8, 2026 •

Copy link
Copy Markdown

With Nette Forms 3.3.0, PHPStan 2.3.5 and phpstan-nette 2.0.15, calling getValues('array') or getUntrustedValues('array') inferred array|array<mixed>. Checking the explicit 'array' argument before the generic class-string/object branch produces array<mixed> while retaining the existing DTO and default ArrayHash clauses.

This changes only the two conditional PHPDoc return declarations. The runtime implementation, parameters and template declarations are unchanged.

Differential verification on PHP 8.5.12:

  • Both APIs preserve array values, default/null ArrayHash behavior, DTO class construction and DTO instance identity/population; baseline and candidate each passed 2 tests / 28 assertions without skips.
  • Explicit DTO class/instance inference and default/null ArrayHash inference stayed unchanged. The existing static precision limit for implicit setMappedType defaults also remains unchanged.
  • Under the same native dependency graph and consumer configuration, the affected consumer analysis went from 17 diagnostics to 0 with only this declaration change.

The verification used the 3.3.0 source and is not a claim that the entire upstream suite or all PHPStan versions were tested. Please let me know if another canonical declaration is preferred.

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