Skip to content

refactor(session): implement Contracts\Session\Session, decouple Store from Symfony (task 3.4) - #40

Open
agissept wants to merge 1 commit into
migration/3.3b-collection-l13from
migration/3.4-session-symfony-decouple
Open

refactor(session): implement Contracts\Session\Session, decouple Store from Symfony (task 3.4)#40
agissept wants to merge 1 commit into
migration/3.3b-collection-l13from
migration/3.4-session-symfony-decouple

Conversation

@agissept

Copy link
Copy Markdown
Member

Stacked di #38 (base migration/3.3b-collection-l13) — retarget ke master setelah #38 merge. Bagian dari chain #35#36#37#38→ini.

Apa

Task 3.4: bawa Illuminate\Session\Store ke bentuk L13 — sekarang implements Illuminate\Contracts\Session\Session (kontrak dari task 3.1), lepas dari Symfony SessionInterface. Ini melepas Session dari HttpFoundation SessionInterface/bag machinery (bagian SCC-1).

Perubahan

  • Session\Store: implements Contracts\Session\Session; buang mesin bag Symfony ($bags/$metaBag/$bagData, registerBag/getBag/getMetadataBag/getBagData, loop bag di loadSession/save, clear()), import Symfony (SessionBagInterface/MetadataBag/Request), dan $lifetime di invalidate()/migrate(). Tambah exists() (wajib kontrak).
  • SymfonySessionDecorator (baru, verbatim v13): jembatan ke Symfony SessionInterface — bungkus Store, set()put(), clear()flush(), bag-method throw BadMethodCallException.
  • Http\Request (mirror v13): setLaravelSession() bungkus Store di decorator; session() return Store un-wrapped; override getSession()/hasSession().
  • 2 callsite $request->setSession($store)setLaravelSession() (Session\Middleware, Application::prepareRequest).
  • Hapus Session/SessionInterface.php + entri compile-list optimize; retarget type-hint Middleware ke kontrak.

Deviasi sengaja (fork-superset, dihapus nanti — bukan penghalang decouple)

  • Keep set()/replace()/remove()/getToken()set() dipakai 7 callsite app; migrasi set()→put() = task B2 terpisah. Keep = nol app-break sekarang.
  • Keep flash keys flash.{new,old} (bukan v13 _flash.*) — data-cutover live-session di window swap; ditandai ponytail: comment.

Verifikasi

  • Full suite 1641 hijau; Session suite 23 hijau; ratchet di baseline (tak nambah pola 4.2). SCC-1 tetap putus.
  • Adversarial (manual): identity Store terjaga (manager driver() singleton = instance yg di-save Middleware), prepareRequest tak double-set, nol ->getSession()-> misuse di fork, app getSession() cuma getId/get (ada di decorator → nilai identik), nol ref app ke interface yg dihapus, tak ada app class extends Store.
  • 3 test request/routing lama di-update ke idiom setLaravelSession.

⚠️ CI merah = inherited dari #38 (kode v13 Collection pakai fungsi native PHP 8.4 array_any dll, CI jalan 8.3) — di-defer sampai base naik ke 8.4, bukan isu task ini.

🤖 Generated with Claude Code

@agissept agissept self-assigned this Sep 11, 2026
…e from Symfony (task 3.4)

Bring Illuminate\Session\Store to the L13 shape: it now implements
Illuminate\Contracts\Session\Session (introduced in task 3.1) instead of the
Symfony-extending Illuminate\Session\SessionInterface. All Symfony HttpFoundation
coupling is removed from the store — the bag machinery ($bags/$metaBag/$bagData,
registerBag/getBag/getMetadataBag/getBagData, the loadSession/save bag loops,
clear()), the SessionBagInterface/MetadataBag/Request imports, and the
$lifetime params on invalidate()/migrate(). Adds the contract-required exists().

The Symfony bridge is the ported v13 SymfonySessionDecorator: Http\Request now
mirrors v13 (setLaravelSession/session()/getSession()/hasSession()) so the store
is wrapped in the decorator for Symfony-facing code while $request->session()
still returns the unwrapped Store. The two setSession callsites (Session\Middleware
and Application::prepareRequest) switch to setLaravelSession. The deleted
SessionInterface.php is dropped from the optimize compile list.

Deliberate fork-superset deviations (removed later, not needed to decouple Symfony):
- keep set()/replace()/remove()/getToken() — set()'s 7 app call sites migrate to
  put() in a later B2 task; dropping now buys no decoupling.
- keep flash.{new,old} keys (not v13 _flash.*) — a live-session data-cutover
  concern for the swap window, marked with a ponytail comment.

SCC-1 stays broken; ratchet unchanged (no new 4.2 patterns). Full suite green
(1641). Session suite green (23); 3 request/routing tests updated to the
setLaravelSession idiom.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@agissept
agissept force-pushed the migration/3.3b-collection-l13 branch from d2abb75 to d35a07b Compare September 11, 2026 09:29
@agissept
agissept force-pushed the migration/3.4-session-symfony-decouple branch from 2b77722 to 6380c1f Compare September 11, 2026 09:29
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