Problem/Motivation
In Twig 3.13 there is a new tag types
introduced. It gives us the ability to declare the types of the template variables. See https://twig.symfony.com/doc/3.x/tags/types.html and https://github.com/twigphp/Twig/issues/4165
Proposed resolution
Add Twig types
to all core templates based on the types in the template preprocess functions. For example block.html.twig
could contain;
{#
/**
* ...
*
* @see template_preprocess_block()
*/
#}
{% types {
plugin_id: 'string',
label: 'string',
configuration: 'array',
in_preview: 'boolean',
content: 'array'
attributes: '\Drupal\Core\Template\Attribute',
...
} %}
...