Psalm: Psalter: structured array with space in index

Created on 26 Apr 2020  路  3Comments  路  Source: vimeo/psalm

Hi,

For the following code:

/**
 * @return int[]
 */
function a(): array{
    return ['a b'=>0];
}

If we run the command vendor\bin\psalm --alter --issues=all

Psalter will transform the docblock into:

/**
 * @return int[]
 *
 * @psalm-return array{a b: int}
 */

However, this kind of notation is not allowed, and psalm will then flag an error:
ERROR: InvalidReturnStatement - test.php:15:12 - The inferred type 'array{a b: int(0)}' does not match the declared return type 'array{ab: int}' for a (see https://psalm.dev/128) return ['a b'=>0];

I guess Psalter could skip the detailed "@psalm-return" when this happens

Thanks

bug

All 3 comments

Hey @orklah, can you reproduce the issue on https://psalm.dev ?

Yeah, Psalm should format this with quotes.

Should be fixed now!

Was this page helpful?
0 / 5 - 0 ratings