FlagAction::execute() has the wrong number of arguments

Created on 11 November 2024, about 2 months ago

In πŸ“Œ Add declare(strict_types=1) to all test modules Active , running phpstan at level 2 on the test cases revealed the following:

 ------ ---------------------------------------------------------------------- 
  Line   tests/src/Kernel/FlagActionTest.php                                   
 ------ ---------------------------------------------------------------------- 
  108    Method Drupal\Core\Executable\ExecutableInterface::execute() invoked  
         with 1 parameter, 0 required.                                         
  121    Method Drupal\Core\Executable\ExecutableInterface::execute() invoked  
         with 1 parameter, 0 required.                                         
 ------ ---------------------------------------------------------------------- 

In short, class FlagAction extends ActionBase. ActionBase implements ExecutableInterface which defines a method ExecutableInterface::execute() with no arguments.
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Executabl...

BUT

FlagAction overrides ExecutableInterface::execute() and adds 1 argument to the method.
This violates the contract of the interface, which phpstan doesn't like.

I'm opening this issue because it's not merely a matter of correcting a phpstan error, it involves an API to the FlagAction class and maybe some rethinking about how this action is defined and used.

πŸ› Bug report
Status

Active

Version

4.0

Component

Actions integration

Created by

πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

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

Comments & Activities

Production build 0.71.5 2024