Skip to content

Add getFlashAll() and getFlashNextAll() to FlashSegmentInterface - #3

Merged
harikt merged 1 commit into
7.xfrom
flash-all-getters
Sep 8, 2026
Merged

harikt merged 1 commit into
7.xfrom
flash-all-getters

Conversation

@harikt

@harikt harikt commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds two methods to FlashSegmentInterface:

public function getFlashAll(): array;
public function getFlashNextAll(): array;

They return every flash value for the current or the next request, so a
consumer can render flash messages without knowing the keys in advance.

ManageableSegmentInterface::getSegment() already covers this for plain
values; there was no flash equivalent, which meant reaching into
$_SESSION[Session::FLASH_NOW][$name] directly. Symfony's FlashBag (all(),
peekAll()) and Laravel both provide the equivalent.

Why now

This was proposed for Aura.Session by @jakejohns in 2016
(auraphp/Aura.Session#47, auraphp/Aura.Session#52) and deferred for one
reason — adding methods to a published interface breaks every implementer.

The 7.0 line is still a pre-release (7.0.0-beta1), so that objection does not
apply yet. Once 7.0.0 is tagged final this becomes an 8.0 change.

On the signature

Neither method takes an $alt argument, which follows getSegment() rather
than the key-based getters. $alt exists to tell "key not set" apart from "key
set to null", and an all-getter has no such ambiguity: there are values or there
are none, and none is []. In this package every $alt is on a key-based
getter (get(), getFlash(), getFlashNext()); the one whole-collection
getter, getSegment(), has none.

Both return array rather than ?array, so the result is always safe to
iterate. This differs slightly from getSegment(), which returns null when
the segment is unset.

Impact

  • Breaking for anyone implementing FlashSegmentInterface — free to do before
    7.0.0 final, and no released version declares it yet.
  • Aura.Auth is unaffected: it uses only the plain SegmentInterface (get/set),
    and its NullSegment / ArraySegment never implement the flash contract.
  • The companion implementation is Add Segment::getFlashAll() and Segment::getFlashNextAll() Aura.Session#107. Merge this and tag
    7.0.0-beta2 first
    , since that branch implements methods this interface
    needs to declare.

Tests

InterfaceContractTest covers both — the signature/return-type table, and the
anonymous class that proves the contracts compose without clashing. 23 tests
pass.

Summary by CodeRabbit

  • New Features

    • Added methods to retrieve all flash values for the current request or the next request without specifying keys.
    • These methods return an empty array when no flash values are available.
  • Documentation

    • Updated the README with guidance for using the new all-value retrieval methods.
  • Breaking Changes

    • Existing implementations must add the two new methods to remain compatible with the beta2 release.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: affcf697-c209-49dd-80da-4dcf8aabdfc8

📥 Commits

Reviewing files that changed from the base of the PR and between 005fb70 and 66f1724.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • README.md
  • src/FlashSegmentInterface.php
  • tests/InterfaceContractTest.php

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The flash segment interface adds methods to retrieve all flash values for the current and next request. The contract test fixture, README, and changelog document the new methods and beta2 compatibility change.

Changes

Flash all-getter contract

Layer / File(s) Summary
Add all-getter methods
src/FlashSegmentInterface.php
FlashSegmentInterface declares getFlashAll(): array and getFlashNextAll(): array.
Update contract validation and documentation
tests/InterfaceContractTest.php, README.md, CHANGELOG.md
The contract test fixture implements both methods. The README documents their return values. The changelog records the beta2 change and its compatibility requirement.

Priority: ⬇️ Low — Defer the flash interface additions because they are a narrow pre-release contract change with no broader product-impact evidence.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 66f17

This change adds documented flash-value collection methods to the pre-release interface and updates its contract coverage. No current merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 2 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: adding getFlashAll() and getFlashNextAll() to FlashSegmentInterface.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 2 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

There was no way to read flash values without knowing their keys in
advance, so rendering a list of flash messages meant reaching into
$_SESSION directly. ManageableSegmentInterface::getSegment() covers this
for plain values; these two do the same for the current and next request.

Neither takes an alternative value. Unlike getFlash(), an all-getter has
no "set to null" case to distinguish from "not set", so the empty array
is the only sensible default.

Proposed for Aura.Session by Jake Johns in 2016 (auraphp/Aura.Session#47
and #52) and deferred because it changed a published interface; the 7.0
line is still a pre-release, so the change is free to make now.
@harikt
harikt merged commit 9f69db8 into 7.x Sep 8, 2026
5 checks passed
@harikt
harikt deleted the flash-all-getters branch September 8, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant