From 1c5e9e7ca3a5fa573e4004d604a9f71835cfba00 Mon Sep 17 00:00:00 2001 From: connor Date: Tue, 9 Apr 2024 08:53:49 +0200 Subject: [PATCH] [storage] improvement: use null coalescing operator --- lib/storage/sfCacheSessionStorage.class.php | 8 +------- lib/storage/sfSessionStorage.class.php | 8 +------- lib/storage/sfSessionTestStorage.class.php | 8 +------- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/lib/storage/sfCacheSessionStorage.class.php b/lib/storage/sfCacheSessionStorage.class.php index 76b9aaf8c..58e2b71b8 100644 --- a/lib/storage/sfCacheSessionStorage.class.php +++ b/lib/storage/sfCacheSessionStorage.class.php @@ -176,13 +176,7 @@ public function write($key, $data) */ public function read($key) { - $retval = null; - - if (isset($this->data[$key])) { - $retval = &$this->data[$key]; - } - - return $retval; + return $this->data[$key] ?? null; } /** diff --git a/lib/storage/sfSessionStorage.class.php b/lib/storage/sfSessionStorage.class.php index 475bd96da..69f8e54de 100644 --- a/lib/storage/sfSessionStorage.class.php +++ b/lib/storage/sfSessionStorage.class.php @@ -105,13 +105,7 @@ public function initialize($options = null) */ public function read($key) { - $retval = null; - - if (isset($_SESSION[$key])) { - $retval = $_SESSION[$key]; - } - - return $retval; + return $_SESSION[$key] ?? null; } /** diff --git a/lib/storage/sfSessionTestStorage.class.php b/lib/storage/sfSessionTestStorage.class.php index 35c770088..8f4822878 100644 --- a/lib/storage/sfSessionTestStorage.class.php +++ b/lib/storage/sfSessionTestStorage.class.php @@ -74,13 +74,7 @@ public function getSessionId() */ public function read($key) { - $retval = null; - - if (isset($this->sessionData[$key])) { - $retval = $this->sessionData[$key]; - } - - return $retval; + return $this->sessionData[$key] ?? null; } /**