tree-sitter-phpdoc icon indicating copy to clipboard operation
tree-sitter-phpdoc copied to clipboard

feat: add support for psalm and phpstan array and list shapes

Open afranioce opened this issue 2 years ago • 2 comments

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)
    {
    }
}

afranioce avatar Aug 02 '23 23:08 afranioce

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!

claytonrcarter avatar Sep 05 '24 01:09 claytonrcarter

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.

claytonrcarter avatar Sep 05 '24 02:09 claytonrcarter