Skip to content

Commit 6de8d08

Browse files
committed
[storage] improvement: use null coalescing operator
1 parent a1ba780 commit 6de8d08

File tree

3 files changed

+3
-21
lines changed

3 files changed

+3
-21
lines changed

lib/storage/sfCacheSessionStorage.class.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,7 @@ public function write($key, $data)
176176
*/
177177
public function read($key)
178178
{
179-
$retval = null;
180-
181-
if (isset($this->data[$key])) {
182-
$retval = &$this->data[$key];
183-
}
184-
185-
return $retval;
179+
return $this->data[$key] ?? null;
186180
}
187181

188182
/**

lib/storage/sfSessionStorage.class.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,7 @@ public function initialize($options = null)
105105
*/
106106
public function read($key)
107107
{
108-
$retval = null;
109-
110-
if (isset($_SESSION[$key])) {
111-
$retval = $_SESSION[$key];
112-
}
113-
114-
return $retval;
108+
return $_SESSION[$key] ?? null;
115109
}
116110

117111
/**

lib/storage/sfSessionTestStorage.class.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,7 @@ public function getSessionId()
7474
*/
7575
public function read($key)
7676
{
77-
$retval = null;
78-
79-
if (isset($this->sessionData[$key])) {
80-
$retval = $this->sessionData[$key];
81-
}
82-
83-
return $retval;
77+
return $this->sessionData[$key] ?? null;
8478
}
8579

8680
/**

0 commit comments

Comments
 (0)