Problem/Motivation

while writing automated tests, I came across the following error message:

Method "Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents()" might add "array" as a native return type declaration in the future. Do the same in implementation "Drupal\views_bulk_operations\EventSubscriber\ViewsBulkOperationsEventSubscriber" now to avoid errors or add an explicit @return annotation to suppress this message.

Steps to reproduce

  1. write a module that includes a view
  2. add VBO to your module's view
  3. write automated tests
  4. run your tests with the --verbose flag

Proposed resolution

I'll be forking a simple patch shortly to fix the required function calls adding the array return type as expected by PHPUnit to future-proof the getSubscribedEvents() implementation.

Remaining tasks

  1. create an issue fork (me)
  2. test the patch as follows:
    1. apply the patch
    2. create a simple module with a VBO-powered view in config/install
    3. write a test for your view
    4. run your test with the --verbose flag
CommentFileSizeAuthor
#2 3617756-adding-return-type.patch1.37 KBluco
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

luco created an issue. See original summary.

luco’s picture

StatusFileSize
new1.37 KB

please find attached a patch for the changes; they were also submitted via a fork.

luco’s picture

hi @Graber,

I just noticed your previous commit after having submitted my patch. sorry!

could you please let me know why were the return types removed?

graber’s picture

Probably backwards compatibility issues like this one https://www.drupal.org/project/views_bulk_operations/issues/3612594 (not this one exactly though)

graber’s picture

Actually.. exactly that one.

graber’s picture

You can use that return type trait so people start using those and we can actually add return types in the next major without breaking anyone’s projects.
Create a MR though, patches mean more work for me and I’m busy.

luco’s picture

lol "exactly that one", gotcha! thanks for getting back to me on this.

MR created; the patch is due to an urgent matter. but I'll definitely try out the trait instead.

pls let me know if you need me to revise anything about my MR, ok?

tolstoydotcom’s picture

I tested this branch by adding a VBO column to an existing view and I was able to delete the selected entity. That's on D11.4/PHP 8.3. I didn't test other configurations.