thecodingmachine / graphqlite

Use PHP Attributes/Annotations to declare your GraphQL API
https://graphqlite.thecodingmachine.io
MIT License
557 stars 98 forks source link

Use @param tags from constructor with property promotion #628

Closed oojacoboo closed 1 year ago

oojacoboo commented 1 year ago

When using property promotion, particularly with input types, you're required to define the generic type details for lists (array, collection, etc) using a variable docblock. Not only is this ugly, it requires duplicate docblock definitions for internal docblock usage and is entirely unnecessary.

This PR adds support for constructor docblock generic type definitions with property promotion.

Example:

/**
 * Constructor
 * 
 * @param array<string> $array
 */
#[Input]
public function __construct(
    #[Field]
    public array $array
) {}

As opposed to:

#[Input]
public function __construct(
    /** @var array<string> */
    #[Field]
    public array $array
) {}

The additional support is fully BC.

oojacoboo commented 1 year ago

Should be ready. A review would be nice.