vimeo / vimeo/psalm

Could not verify return type when union array<> and arraylike-object<>

Open
#4,875 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
5.9k
Forks
708
Avg merge
2d 3h
Merged PRs (30d)
25

Description

Hi,

I am not sure if I am missing something, but I would expect that psalm could identify the return type here.

See https://psalm.dev/r/a113e1d2e7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported case using the Psalm playground link https://psalm.dev/r/a113e1d2e7 and compare the inferred return type with the expected type. Trace the type-inference path for a union of array and arraylike-object, then add coverage demonstrating the expected result once the relevant implementation area is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.