File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed
Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 66namespace Valar \Http \Config ;
77
88use Mvc5 \Arg ;
9+ use Mvc5 \Cookie \HttpCookies ;
910
1011trait ServerRequest
1112{
@@ -37,8 +38,7 @@ function getAttributes() : array
3738 */
3839 function getCookieParams () : array
3940 {
40- /** @var array|\Traversable $cookies */
41- return is_array ($ cookies = $ this [Arg::COOKIES ] ?? []) ? $ cookies : \iterator_to_array ($ cookies );
41+ return $ this [Arg::COOKIES ]->all ();
4242 }
4343
4444 /**
@@ -98,7 +98,7 @@ function withoutAttribute($name)
9898 */
9999 function withCookieParams (array $ cookies )
100100 {
101- return $ this ->with (Arg::COOKIES , $ cookies );
101+ return $ this ->with (Arg::COOKIES , new HttpCookies ( $ cookies) );
102102 }
103103
104104 /**
Original file line number Diff line number Diff line change 66namespace Valar \Http ;
77
88use Mvc5 \Arg ;
9+ use Mvc5 \Cookie \HttpCookies ;
910use Mvc5 \Http \HttpHeaders ;
1011use Psr \Http \Message \ServerRequestInterface ;
1112use Zend \Diactoros \PhpInputStream ;
@@ -40,10 +41,15 @@ function __construct($config = [])
4041 ServerRequestFactory::marshalUriFromServer ($ server , \iterator_to_array ($ config [Arg::HEADERS ]))
4142 );
4243
44+ !isset ($ config [Arg::COOKIES ]) &&
45+ $ config [Arg::COOKIES ] = new HttpCookies ($ _COOKIE );
46+
47+ is_array ($ config [Arg::COOKIES ]) &&
48+ $ config [Arg::COOKIES ] = new HttpCookies ($ config [Arg::COOKIES ]);
49+
4350 !isset ($ config [Arg::ARGS ]) && $ config [Arg::ARGS ] = $ _GET ;
4451 !isset ($ config [Arg::ATTRIBUTES ]) && $ config [Arg::ATTRIBUTES ] = [];
4552 !isset ($ config [Arg::BODY ]) && $ config [Arg::BODY ] = new PhpInputStream ;
46- !isset ($ config [Arg::COOKIES ]) && $ config [Arg::COOKIES ] = $ _COOKIE ;
4753 !isset ($ config [Arg::DATA ]) && $ config [Arg::DATA ] = $ _POST ;
4854 !isset ($ config [Arg::FILES ]) && $ config [Arg::FILES ] = ServerRequestFactory::normalizeFiles ($ _FILES );
4955 !isset ($ config [Arg::METHOD ]) && $ config [Arg::METHOD ] = $ server ['REQUEST_METHOD ' ] ?? 'GET ' ;
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ function test_get_cookie_params()
4646 /**
4747 *
4848 */
49- function test_get_cookie_params_from_traversable ()
49+ function test_get_cookie_params_from_http_cookies ()
5050 {
5151 $ request = new ServerRequest (['cookies ' => new HttpCookies (['foo ' => 'bar ' ])]);
5252
You can’t perform that action at this time.
0 commit comments