Add support for new `types` tag
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.
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[]',
} %}
@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.
@Haehnchen I'd love to get your feedback on my previous comment.
@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.