Haehnchen / idea-php-symfony2-plugin

IntelliJ IDEA / PhpStorm Symfony Plugin
https://plugins.jetbrains.com/plugin/7219
MIT License
913 stars 137 forks source link

Add support for new `types` tag #2396

Open drjayvee opened 2 months ago

drjayvee commented 2 months ago

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.

Haehnchen commented 1 month ago

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

drjayvee commented 2 weeks ago

@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.