1010
1111namespace Arachne \Codeception \Http ;
1212
13+ use Nette \Http \Helpers ;
1314use Nette \Http \IResponse ;
1415use Nette \Http \Response as HttpResponse ;
15- use Nette \Object ;
1616use Nette \Utils \DateTime ;
1717
1818/**
1919 * HttpResponse class for tests.
2020 *
2121 * @author Jáchym Toušek <[email protected] > 2222 */
23- class Response extends Object implements IResponse
23+ class Response implements IResponse
2424{
2525 /**
2626 * @var int
@@ -39,11 +39,11 @@ public function reset()
3939 }
4040
4141 /**
42- * @param int
42+ * @param int $code
4343 *
44- * @return self
44+ * @return static
4545 */
46- public function setCode ($ code )
46+ public function setCode (int $ code )
4747 {
4848 $ this ->code = $ code ;
4949
@@ -53,7 +53,7 @@ public function setCode($code)
5353 /**
5454 * @return int
5555 */
56- public function getCode ()
56+ public function getCode (): int
5757 {
5858 return $ this ->code ;
5959 }
@@ -62,9 +62,9 @@ public function getCode()
6262 * @param string $name
6363 * @param string $value
6464 *
65- * @return self
65+ * @return static
6666 */
67- public function setHeader ($ name , $ value )
67+ public function setHeader (string $ name , string $ value )
6868 {
6969 $ this ->headers [$ name ] = $ value ;
7070
@@ -75,9 +75,9 @@ public function setHeader($name, $value)
7575 * @param string $name
7676 * @param string $value
7777 *
78- * @return self
78+ * @return static
7979 */
80- public function addHeader ($ name , $ value )
80+ public function addHeader (string $ name , string $ value )
8181 {
8282 $ this ->headers [$ name ] = $ value ;
8383
@@ -88,9 +88,9 @@ public function addHeader($name, $value)
8888 * @param string $type
8989 * @param string $charset
9090 *
91- * @return self
91+ * @return static
9292 */
93- public function setContentType ($ type , $ charset = null )
93+ public function setContentType (string $ type , string $ charset = null )
9494 {
9595 $ this ->setHeader ('Content-Type ' , $ type .($ charset ? '; charset= ' .$ charset : '' ));
9696
@@ -101,7 +101,7 @@ public function setContentType($type, $charset = null)
101101 * @param string $url
102102 * @param int $code
103103 */
104- public function redirect ($ url , $ code = self ::S302_FOUND )
104+ public function redirect (string $ url , int $ code = self ::S302_FOUND ): void
105105 {
106106 $ this ->setCode ($ code );
107107 $ this ->setHeader ('Location ' , $ url );
@@ -110,7 +110,7 @@ public function redirect($url, $code = self::S302_FOUND)
110110 /**
111111 * @param string|int|DateTime $time
112112 *
113- * @return self
113+ * @return static
114114 */
115115 public function setExpiration ($ time )
116116 {
@@ -123,34 +123,33 @@ public function setExpiration($time)
123123
124124 $ time = DateTime::from ($ time );
125125 $ this ->setHeader ('Cache-Control ' , 'max-age= ' .($ time ->format ('U ' ) - time ()));
126- $ this ->setHeader ('Expires ' , HttpResponse:: date ($ time ));
126+ $ this ->setHeader ('Expires ' , Helpers:: formatDate ($ time ));
127127
128128 return $ this ;
129129 }
130130
131131 /**
132132 * @return bool
133133 */
134- public function isSent ()
134+ public function isSent (): bool
135135 {
136136 return false ;
137137 }
138138
139139 /**
140140 * @param string $name
141- * @param mixed $default
142141 *
143142 * @return mixed
144143 */
145- public function getHeader ($ name , $ default = null )
144+ public function getHeader (string $ name ): ? string
146145 {
147- return isset ( $ this ->headers [$ name ]) ? $ this -> headers [ $ name ] : $ default ;
146+ return $ this ->headers [$ name ] ?? null ;
148147 }
149148
150149 /**
151150 * @return array
152151 */
153- public function getHeaders ()
152+ public function getHeaders (): array
154153 {
155154 return $ this ->headers ;
156155 }
@@ -166,7 +165,7 @@ public function getHeaders()
166165 *
167166 * @return self
168167 */
169- public function setCookie ($ name , $ value , $ time , $ path = null , $ domain = null , $ secure = null , $ httpOnly = null )
168+ public function setCookie (string $ name , string $ value , $ time , string $ path = null , string $ domain = null , bool $ secure = null , bool $ httpOnly = null , string $ sameSite = null )
170169 {
171170 return $ this ;
172171 }
@@ -177,11 +176,7 @@ public function setCookie($name, $value, $time, $path = null, $domain = null, $s
177176 * @param string $domain
178177 * @param bool $secure
179178 */
180- public function deleteCookie ($ name , $ path = null , $ domain = null , $ secure = null )
181- {
182- }
183-
184- public function removeDuplicateCookies ()
179+ public function deleteCookie (string $ name , string $ path = null , string $ domain = null , bool $ secure = null ): void
185180 {
186181 }
187182}
0 commit comments