@@ -54,11 +54,10 @@ public function __construct()
5454
5555 /**
5656 * Sets HTTP response code.
57- * @return static
5857 * @throws Nette\InvalidArgumentException if code is invalid
5958 * @throws Nette\InvalidStateException if HTTP headers have been sent
6059 */
61- public function setCode (int $ code , string $ reason = null )
60+ public function setCode (int $ code , string $ reason = null ): static
6261 {
6362 if ($ code < 100 || $ code > 599 ) {
6463 throw new Nette \InvalidArgumentException ("Bad HTTP response ' $ code'. " );
@@ -83,10 +82,9 @@ public function getCode(): int
8382
8483 /**
8584 * Sends an HTTP header and overwrites previously sent header of the same name.
86- * @return static
8785 * @throws Nette\InvalidStateException if HTTP headers have been sent
8886 */
89- public function setHeader (string $ name , ?string $ value )
87+ public function setHeader (string $ name , ?string $ value ): static
9088 {
9189 self ::checkHeaders ();
9290 if ($ value === null ) {
@@ -102,10 +100,9 @@ public function setHeader(string $name, ?string $value)
102100
103101 /**
104102 * Sends an HTTP header and doesn't overwrite previously sent header of the same name.
105- * @return static
106103 * @throws Nette\InvalidStateException if HTTP headers have been sent
107104 */
108- public function addHeader (string $ name , string $ value )
105+ public function addHeader (string $ name , string $ value ): static
109106 {
110107 self ::checkHeaders ();
111108 header ($ name . ': ' . $ value , false );
@@ -115,10 +112,9 @@ public function addHeader(string $name, string $value)
115112
116113 /**
117114 * Deletes a previously sent HTTP header.
118- * @return static
119115 * @throws Nette\InvalidStateException if HTTP headers have been sent
120116 */
121- public function deleteHeader (string $ name )
117+ public function deleteHeader (string $ name ): static
122118 {
123119 self ::checkHeaders ();
124120 header_remove ($ name );
@@ -128,10 +124,9 @@ public function deleteHeader(string $name)
128124
129125 /**
130126 * Sends a Content-type HTTP header.
131- * @return static
132127 * @throws Nette\InvalidStateException if HTTP headers have been sent
133128 */
134- public function setContentType (string $ type , string $ charset = null )
129+ public function setContentType (string $ type , string $ charset = null ): static
135130 {
136131 $ this ->setHeader ('Content-Type ' , $ type . ($ charset ? '; charset= ' . $ charset : '' ));
137132 return $ this ;
@@ -140,10 +135,9 @@ public function setContentType(string $type, string $charset = null)
140135
141136 /**
142137 * Response should be downloaded with 'Save as' dialog.
143- * @return static
144138 * @throws Nette\InvalidStateException if HTTP headers have been sent
145139 */
146- public function sendAsFile (string $ fileName )
140+ public function sendAsFile (string $ fileName ): static
147141 {
148142 $ this ->setHeader (
149143 'Content-Disposition ' ,
@@ -172,10 +166,9 @@ public function redirect(string $url, int $code = self::S302_FOUND): void
172166 /**
173167 * Sets the expiration of the HTTP document using the `Cache-Control` and `Expires` headers.
174168 * The parameter is either a time interval (as text) or `null`, which disables caching.
175- * @return static
176169 * @throws Nette\InvalidStateException if HTTP headers have been sent
177170 */
178- public function setExpiration (?string $ time )
171+ public function setExpiration (?string $ time ): static
179172 {
180173 $ this ->setHeader ('Pragma ' , null );
181174 if (!$ time ) { // no cache
@@ -251,7 +244,6 @@ public function __destruct()
251244 /**
252245 * Sends a cookie.
253246 * @param string|int|\DateTimeInterface $time expiration time, value null means "until the browser session ends"
254- * @return static
255247 * @throws Nette\InvalidStateException if HTTP headers have been sent
256248 */
257249 public function setCookie (
@@ -263,7 +255,7 @@ public function setCookie(
263255 bool $ secure = null ,
264256 bool $ httpOnly = null ,
265257 string $ sameSite = null ,
266- ) {
258+ ): static {
267259 self ::checkHeaders ();
268260 $ options = [
269261 'expires ' => $ time ? (int ) DateTime::from ($ time )->format ('U ' ) : 0 ,
0 commit comments