diff options
Diffstat (limited to 'lib/Minz/Request.php')
| -rw-r--r-- | lib/Minz/Request.php | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index af2ba1243..0ac1a9fe3 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -1,4 +1,6 @@ <?php +declare(strict_types=1); + /** * MINZ - Copyright 2011 Marien Fressinaud * Sous licence AGPL3 <http://www.gnu.org/licenses/> @@ -333,7 +335,7 @@ class Minz_Request { private static function setNotification(string $type, string $content): void { Minz_Session::lock(); - $requests = Minz_Session::param('requests', []); + $requests = Minz_Session::paramArray('requests'); $requests[self::requestId()] = [ 'time' => time(), 'notification' => [ 'type' => $type, 'content' => $content ], @@ -350,14 +352,15 @@ class Minz_Request { self::setNotification('bad', $content); } - /** @return array<string,string>|null */ + /** @return array{type:string,content:string}|null */ public static function getNotification(): ?array { $notif = null; Minz_Session::lock(); - $requests = Minz_Session::param('requests'); - if (is_array($requests)) { + /** @var array<string,array{time:int,notification:array{type:string,content:string}}> */ + $requests = Minz_Session::paramArray('requests'); + if (!empty($requests)) { //Delete abandoned notifications - $requests = array_filter($requests, static function (array $r) { return isset($r['time']) && $r['time'] > time() - 3600; }); + $requests = array_filter($requests, static function (array $r) { return $r['time'] > time() - 3600; }); $requestId = self::requestId(); if (!empty($requests[$requestId]['notification'])) { |
