Prevent false positive error messages

Created on 4 September 2023, about 1 year ago

Problem/Motivation

I just got this error message when extracting strings:

The first parameter to info() should be a literal string. There should be no variables, concatenation, constants or other non-literal strings there. At info(sprintf("%d profiles deleted.",count($profiles))) in src/Commands/CleanupProfilesCommands.php on line 171. Read more at http://drupal.org/node/322732

I understand the meaning of the error, but i this case it is just wrong because it detected

Symfony\Component\Console\Style\SymfonyStyle::info(string|array $message)

which like other methods of that class are not translatable.

Steps to reproduce

Create a custom Drush command (class extending Drush\Commands\DrushCommands) and create a call to $this->io()->info() passing a variable or anything else than a string literal.

Proposed resolution

The method detection should not only rely on the method name but better on its full signature or class/interface which defines it.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇦🇹Austria mvonfrie

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

Comments & Activities

Production build 0.71.5 2024