idea-php-symfony2-plugin icon indicating copy to clipboard operation
idea-php-symfony2-plugin copied to clipboard

Add support for new `types` tag

Open drjayvee opened this issue 1 year ago • 4 comments

Twig has just added a new types tag which will be the official way of documenting variable types.

This can eventually replace the community convention of using {# @var #} comments.

Aside from official support and specification, comments have one major downside: they aren't added to the AST, so Twig extensions can't use them.

drjayvee avatar Aug 30 '24 07:08 drjayvee

There is a new release with a first implementation, its allows to use types as classes and arrays.

{% types {
    foobar: '\App\Entity\ErrorReport',
    foobars: '\App\Entity\ErrorReport[]',
} %}

image

image

image

Haehnchen avatar Sep 19 '24 15:09 Haehnchen

@Haehnchen, I'd like to align TwigQI's support for types with the plugin's since we use both at AlisQI.

Do you have plans to add support for nullable types? Would you prefer Type|null or ?Type?

What about iterable<ValueType> and iterable<KeyType, ValueType>? Since keys can only be number / int or string, I don't think the plugin needs to do all that much with key types. But recognizing the values' type would be really useful.

Or do you prefer to align with PHPStan-style array<>, array{}, list, etc, and try to support some/many/all of the different variations? (See #1733)

I'd love to have a chat with you about this if you want.

drjayvee avatar Oct 25 '24 09:10 drjayvee

@Haehnchen I'd love to get your feedback on my previous comment.

drjayvee avatar Nov 15 '24 13:11 drjayvee

@Haehnchen Would it be possible to make the types in {% types %} clickable too? For example:

{% types {
    payment: 'App\Payment',
} %}

I'd like to CMD + Click on the App\Payment to navigate there.

ruudk avatar Nov 20 '24 08:11 ruudk