File tree 2 files changed +23
-1
lines changed
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -438,7 +438,7 @@ public function setEncrypted(bool $encrypt = true): self
438
438
/**
439
439
* Push our storage state to the source for persistence.
440
440
*
441
- * @psalm-suppress UnusedFunctionCall
441
+ * @psalm-suppress UnusedFunctionCall,DocblockTypeContradiction
442
442
*
443
443
* @param bool $force
444
444
*/
@@ -458,6 +458,10 @@ public function setState(
458
458
foreach (array_keys ($ _COOKIE ) as $ cookieName ) {
459
459
$ cookieBeginsWith = $ this ->namespace . self ::KEY_SEPARATOR ;
460
460
461
+ if (is_int ($ cookieName )) {
462
+ $ cookieName = (string ) $ cookieName ;
463
+ }
464
+
461
465
if (mb_strlen ($ cookieName ) >= mb_strlen ($ cookieBeginsWith )
462
466
&& mb_substr ($ cookieName , 0 , mb_strlen ($ cookieBeginsWith )) === $ cookieBeginsWith ) {
463
467
$ existing [] = $ cookieName ;
Original file line number Diff line number Diff line change 249
249
$ this ->store ->setEncrypted (false );
250
250
expect ($ this ->store ->encrypt ($ state , ['encoded1 ' => false ]))->toEqual ('' );
251
251
});
252
+
253
+ it ('enumerates $_COOKIE with non-string keys ' , function (array $ state ): void {
254
+ $ cookieNamespace = $ this ->store ->getNamespace () . '_0 ' ;
255
+
256
+ $ encrypted = MockCrypto::cookieCompatibleEncrypt ($ this ->cookieSecret , [$ this ->exampleKey => $ state ]);
257
+
258
+ $ _COOKIE [$ cookieNamespace ] = $ encrypted ;
259
+ $ _COOKIE ['123 ' ] = uniqid ();
260
+ $ _COOKIE [456 ] = uniqid ();
261
+ $ _COOKIE ['abc ' ] = uniqid ();
262
+
263
+ $ this ->store ->getState ();
264
+ $ this ->store ->setState (true );
265
+
266
+ expect ($ this ->store ->get ($ this ->exampleKey ))->toEqual ($ state );
267
+ })->with (['mocked state ' => [
268
+ fn () => MockDataset::state ()
269
+ ]]);
You can’t perform that action at this time.
0 commit comments