Skip to content

Use list-shapes for functionMap return types that are guaranteed lists#6024

Open
zonuexe wants to merge 1 commit into
phpstan:2.2.xfrom
zonuexe:functionmap-list-shapes
Open

Use list-shapes for functionMap return types that are guaranteed lists#6024
zonuexe wants to merge 1 commit into
phpstan:2.2.xfrom
zonuexe:functionmap-list-shapes

Conversation

@zonuexe

@zonuexe zonuexe commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Spell functionMap return types that are guaranteed lists as list{...}.

Semantically a no-op today (both spellings resolve to the same type) — this prevents these signatures from losing list-ness under the stricter array-shape semantics proposed in phpstan/phpstan#14939.

Supersedes the functionMap part of #3872 (adds hrtime, preg_split with PREG_SPLIT_OFFSET_CAPTURE, and sys_getloadavg; excludes getimagesize — string keys, a genuine map — and each — its runtime key order 1, 'value', 0, 'key' is genuinely not a list).

These functions return arrays whose keys are always 0..n-1 in ascending
order, so spell them as list{...} instead of array{...} / array{0: ...}.

Currently a semantic no-op (both spellings resolve to the same type), but
it keeps these signatures list-typed under the stricter array-shape
semantics proposed in phpstan/phpstan#14939, where plain array-shapes
no longer guarantee key order.

Refs phpstan/phpstan#14939
@VincentLanglet VincentLanglet requested a review from staabm July 8, 2026 17:43
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