Problem/Motivation
`MessengerInterface::deleteAll()` has an incorrect return type in its docblock.
It currently documents a flat array of messages, matching `messagesByType($type)`, but the implementation returns all messages grouped by message type, matching `MessengerInterface::all()`.
Steps to reproduce
Proposed resolution
Update the @return docblock for MessengerInterface::deleteAll() to document the nested array structure returned by the implementation.
Remaining tasks
- Review the merge request.
User interface changes
Introduced terminology
API changes
The documented return type for `MessengerInterface::deleteAll()` is corrected from a flat array to an array grouped by message type.
Data model changes
None
Release notes snippet
None
Issue fork drupal-3593122
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:
- 3593122-messengerinterfacedeleteall-has-the
changes, plain diff MR !15990
Comments
Comment #2
nicxvan commentedComment #6
avinash.jha commentedFixed the @return docblock for deleteAll() — changed from string[]|MarkupInterface[] to string[][]|MarkupInterface[][] to match ::all(),
Please review and let me know if anything more required
Comment #7
avinash.jha commentedComment #8
smustgrave commentedSince this is a novice tagged task may be good practice to make sure the summary is updated too.
@avinash.jha mind expanding on how you came up with that one please?
Thanks.
Comment #9
avinash.jha commentedHi @smustgrave
I followed these steps to determine the correct change:
1. The issue description notes: *"It should be the same as ::all() but it is the same as messagesByType($type);"*
2. I checked the implementation in `Messenger::deleteAll()`, which returns `$this->flashBag->clear()`.
3. Looking at Symfony's `FlashBag` class, the `clear()` method clears all flash messages and returns them. Internally, this returns the entire `$this->flashes` array (which is grouped by message type, e.g. `['status' => [...], 'warning' => [...], 'error' => [...]]`).
4. This is the exact same structure returned by `peekAll()` (which is called by `Messenger::all()`).
5. Since the original docblock for `deleteAll()` incorrectly documented a flat array (`string[]|MarkupInterface[]`), I corrected it to a nested array (`string[][]|MarkupInterface[][]`) to match the actual implementation and align it with `::all()`.
Comment #10
brandonlira commentedComment #11
brandonlira commentedUpdated the issue summary with the problem, proposed resolution, remaining tasks, and API changes.
The MR is still mergeable and the pipeline is passing. Moving back to Needs review.
Comment #12
smustgrave commentedNot sure the original purpose was to copy word for word the description from all(). Think that needs to be looked at.
Comment #13
brandonlira commentedComment #14
brandonlira commentedHi @smustgrave,
Updated the MR to avoid copying the ::all() return description word for word.
The deleteAll() docblock now keeps the corrected nested return type, but describes the returned values as deleted messages grouped by message type.
The branch was also rebased against the latest main, and the pipeline is passing now.
Moving back to Needs review.
Comment #15
smustgrave commentedReads much better, thanks!
Comment #16
larowlanLeft a comment on the MR about a further improvement - don't make that change yet until we get consensus here - thoughts folks?
Comment #17
smustgrave commentedIf we do do we update all() too?
Comment #18
larowlanWould make sense if we agree with the approach
Comment #19
dcam commented+1 for using the array shape. We're using shapes more and more lately. With those in place we can simplify the return type descriptions too, removing the explanations that specify what the message types are. They become part of the function definition.
Comment #20
smustgrave commentedThat’s 3 let’s do it!
Comment #21
brandonlira commentedUpdated the MR as suggested.
Both ::all() and ::deleteAll() now use the array shape return type, and the branch was rebased against latest main.
Thanks!
Comment #22
dcam commentedThis looks correct to me, thanks for working on it!
Comment #25
catchCommitted/pushed to main and 11.x, thanks!