Psalm: PhpStorm generics stopped working

Created on 15 Feb 2019  路  4Comments  路  Source: vimeo/psalm

Getting "Cannot determine the type of the object" for this method:

    /**
     * @return \Traversable|HasErrorCode[]
     */
    public function getMessages();

Example: https://getpsalm.org/r/ef4492f426

$ php vendor/bin/psalm -v
Psalm 3.0.15@c310a2dd86660944b3f15fb8486ab73d45066618
$ grep Gene psalm.xml 
    allowPhpStormGenerics="true"

(Were they working before? I don't know.)

Workaround is to use @return \Traversable|HasErrorCode[]|\Traversable<HasErrorCode>, but shouldn't it be working as it is? Demo with this workaround.

bug

Most helpful comment

All 4 comments

+1, same issue for me

It was definitely working before - Psalm is collapsing Traversable|array into iterable, but it shouldn't _if_ the config flag is on and the Traversable is also in the return param hint

I'll release a build with this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

roukmoute picture roukmoute  路  3Comments

tux-rampage picture tux-rampage  路  3Comments

Ocramius picture Ocramius  路  3Comments

greg0ire picture greg0ire  路  3Comments

albe picture albe  路  3Comments