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
- write a module that includes a view
- add VBO to your module's view
- write automated tests
- 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
- create an issue fork (me)
- test the patch as follows:
- apply the patch
- create a simple module with a VBO-powered view in config/install
- write a test for your view
- run your test with the --verbose flag
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3617756-adding-return-type.patch | 1.37 KB | luco |
Issue fork views_bulk_operations-3617756
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
Comment #2
luco commentedplease find attached a patch for the changes; they were also submitted via a fork.
Comment #3
luco commentedhi @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?
Comment #4
graber commentedProbably backwards compatibility issues like this one https://www.drupal.org/project/views_bulk_operations/issues/3612594 (not this one exactly though)
Comment #5
graber commentedActually.. exactly that one.
Comment #6
graber commentedYou 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.
Comment #8
luco commentedlol "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?
Comment #9
tolstoydotcomI 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.