Change record status: 
Project: 
Introduced in branch: 
12.0.x
Introduced in version: 
12.0.0
Description: 

Drupal uses Symfony's DebugClassLoader in tests, which detects missing return types in code by analysing docblocks. This means that libraries such as Symfony can add @return annotations to indicate to users of their code that return types will be added in the next major version.

Because all Drupal code shares the \Drupal namespace, these checks were not triggered for missing return types in Drupal modules and themes. The DebugClassLoader has been extended so contrib modules and custom code will now be notified via deprecations that they should add return types. In a future major release, Drupal core will then add the return types.

This change means that if you implement a Drupal interface or override an upstream method without adding a return type, you will start to see deprecations in the following format:

Method "Drupal\Core\Security\TrustedCallbackInterface::trustedCallbacks()" might add "array" as a native return type declaration in the future. Do the same in implementation "Drupal\my_module\Plugin\views\field\MyField" now to avoid errors or add an explicit @return annotation to suppress this message.
Impacts: 
Module developers
Themers
Site templates, recipes and distribution developers