Support array shapes
Support array shapes such as array{someKey:?string}
during type deduction and autocompletion:
Syntax Support
Parsing these is already supported because we use PHPStan's docblock type parser. The type of these nodes is ArrayShapeNode
. Be wary of spaces, though, since our docblock parser sees spaces as the end of the type at the moment (#318).
Intelligent Array Shape Type Deduction
We can guess detailed array shapes instead of just array
when assigning an array value to a variable:
$a = ['key' => 2, 'other' => 'test'];
// $a is now of type array{key:int,other:string}.
$a['more'] = 8;
// $a is now of type array{key:int,other:string,more:int}.
Autocompletion
We can suggest (int
or string
) array keys during autocompletion when typing $a[
.