FilterInterface::tips return does not match core implementations

Created on 7 July 2023, about 1 year ago
Updated 14 July 2023, about 1 year ago

Problem/Motivation

While checking the Glossary 2 module with phpstan, I noticed a warning about the tips method.

FilterInterface::tips() is defined as:

  /**
   * ...snip...
   *
   * @return string|null
   *   Translated text to display as a tip, or NULL if this filter has no tip.
   */
  public function tips($long = FALSE);

However, all implementations in core actually return TranslatableMarkup|null.

Steps to reproduce

Read all filter implementations in core.

Proposed resolution

  • Modify FilterInterface to match what code actually does: update the PHPdoc to @return \Drupal\Core\StringTranslation|null
  • Optional: add a return type hint: public function tips($long = FALSE): ?TranslatableMarkup . I'm not sure where we stand on return typing for D10.

Remaining tasks

Decide on the return typing.

User interface changes

None.

API changes

If it is just a phpdoc, none. If we type the return value, it may qualify as an API change, but one that matches core implementations, and those implementations I looked at in contrib.

Data model changes

None.

Release notes snippet

None.

🐛 Bug report
Status

Needs work

Version

10.1

Component
Filter 

Last updated 2 days ago

No maintainer
Created by

🇫🇷France fgm Paris, France

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024