tree-sitter-phpdoc
tree-sitter-phpdoc copied to clipboard
feat: add support for psalm and phpstan array and list shapes
Add support for a special format for list arrays
- Array shapes: https://psalm.dev/docs/annotating_code/type_syntax/array_types/#array-shapes
- List shapes: https://psalm.dev/docs/annotating_code/type_syntax/array_types/#list-shapes
<?php
class Foo {
/**
* @param array{criteria: string, handler: Bar} $handlers
*/
public function singleLine(array $handlers)
{
}
/**
* @param array {
* criteria: string,
* handler: Bar
* } $handlers
*/
public function multipleLines(array $handlers)
{
}
}
I had always intended to add support for array shapes, but I ran out of steam at some point and never got to it. (And I guess I don't use them as much as I thought I would at that time. 😆) I would welcome a PR that adds support for array and list shapes, though!
Ah ha. I found an old branch where I had started on support for array shapes. It's now been dusted off and pushed to #39; please take a look and let me know what you think.