vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.55k stars 659 forks source link

Allow index access to subtypes. #7964

Open rzvc opened 2 years ago

rzvc commented 2 years ago
/**
* @psalm-type Shape = array{ a: string }
* @param Shape[a] $x
*/
function test($x) : void
{
    print_r($x);
}

https://psalm.dev/r/9584255613

Typescript has this, in the form Interface['a'].

psalm-github-bot[bot] commented 2 years ago

I found these snippets:

https://psalm.dev/r/9584255613 ```php