Skip to content

Commit 32e152e

Browse files
committed
fix: patch up withFlash function
1 parent 78dca3c commit 32e152e

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/Response.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function httpVersion(?string $version = null)
5656

5757
/**
5858
* Output any text
59-
*
59+
*
6060
* @param string $data The data to output
6161
* @param int $code The response status code
6262
*/
@@ -98,10 +98,10 @@ public function xml(string $data, int $code = 200)
9898

9999
$this->send();
100100
}
101-
101+
102102
/**
103103
* Output js script
104-
*
104+
*
105105
* @param string $data The data to output
106106
* @param int $code The response status code
107107
*/
@@ -245,7 +245,7 @@ public function exit($data, int $code = 500)
245245

246246
/**
247247
* Output some data and break the application
248-
*
248+
*
249249
* @param mixed $data The data to output
250250
* @param int $code The Http status code
251251
*/
@@ -284,7 +284,7 @@ public function redirect($url, int $status = 302)
284284

285285
/**
286286
* Pass data to the route handler
287-
*
287+
*
288288
* @param mixed $data The data to pass
289289
*/
290290
public function next($data)
@@ -383,9 +383,11 @@ public function withoutCookie($name): Response
383383
* Flash a piece of data to the session.
384384
*
385385
* @param string|array key The key of the item to set
386-
* @param string $value The value of flash item
386+
* @param mixed $value The value of flash item
387+
*
388+
* @return Response
387389
*/
388-
public function withFlash($key, string $value): Response
390+
public function withFlash($key, $value = null): Response
389391
{
390392
if (!class_exists('Leaf\Http\Session')) {
391393
Headers::contentHtml();
@@ -398,7 +400,7 @@ public function withFlash($key, string $value): Response
398400
}
399401
}
400402

401-
\Leaf\Flash::set($key, $value);
403+
\Leaf\Flash::set($value, $key);
402404

403405
return $this;
404406
}

0 commit comments

Comments
 (0)