fix(session): initialize data lazily in save() to prevent uninitialized property access (#252)

This commit is contained in:
Antoine Bluchet 2026-03-05 00:07:49 +01:00 • committed by GitHub
commit 61c20f1450
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,6 +34,15 @@ class SessionTest extends TestCase
$this->assertEquals(['foo' => 'bar'], $result);
}
public function testSaveBeforeReadInitializesData()
{
$store = new InMemorySessionStore();
$session = new Session($store);
// save() before any get()/set() should not crash
$this->assertTrue($session->save());
}
public function testAllReturnsEmptyArrayForNullPayload()
{
$store = $this->getMockBuilder(InMemorySessionStore::class)