Skip to content

Commit 4e19251

Browse files
committed
[action] improvement: use null coalescing operator
1 parent ddc1528 commit 4e19251

File tree

2 files changed

+4
-31
lines changed

2 files changed

+4
-31
lines changed

Diff for: lib/action/sfAction.class.php

+1-9
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,7 @@ public function getSecurityValue($name, $default = null)
388388
{
389389
$actionName = strtolower($this->getActionName());
390390

391-
if (isset($this->security[$actionName][$name])) {
392-
return $this->security[$actionName][$name];
393-
}
394-
395-
if (isset($this->security['all'][$name])) {
396-
return $this->security['all'][$name];
397-
}
398-
399-
return $default;
391+
return $this->security[$actionName][$name] ?? $this->security['all'][$name] ?? $default;
400392
}
401393

402394
/**

Diff for: lib/action/sfActionStack.class.php

+3-22
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,7 @@ public function addEntry($moduleName, $actionName, $actionInstance)
4949
*/
5050
public function getEntry($index)
5151
{
52-
$retval = null;
53-
54-
if ($index > -1 && $index < count($this->stack)) {
55-
$retval = $this->stack[$index];
56-
}
57-
58-
return $retval;
52+
return $this->stack[$index] ?? null;
5953
}
6054

6155
/**
@@ -75,13 +69,7 @@ public function popEntry()
7569
*/
7670
public function getFirstEntry()
7771
{
78-
$retval = null;
79-
80-
if (isset($this->stack[0])) {
81-
$retval = $this->stack[0];
82-
}
83-
84-
return $retval;
72+
return $this->stack[0] ?? null;
8573
}
8674

8775
/**
@@ -91,14 +79,7 @@ public function getFirstEntry()
9179
*/
9280
public function getLastEntry()
9381
{
94-
$count = count($this->stack);
95-
$retval = null;
96-
97-
if (isset($this->stack[0])) {
98-
$retval = $this->stack[$count - 1];
99-
}
100-
101-
return $retval;
82+
return $this->stack[count($this->stack) - 1] ?? null;
10283
}
10384

10485
/**

0 commit comments

Comments
 (0)