Skip to content

Commit 72f26da

Browse files
committed
utilization of operator ??
1 parent 830f1e2 commit 72f26da

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/Utils/Callback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public static function unwrap(\Closure $closure)
177177
$r = new \ReflectionFunction($closure);
178178
if (substr($r->getName(), -1) === '}') {
179179
$vars = $r->getStaticVariables();
180-
return isset($vars['_callable_']) ? $vars['_callable_'] : $closure;
180+
return $vars['_callable_'] ?? $closure;
181181

182182
} elseif ($obj = $r->getClosureThis()) {
183183
return [$obj, $r->getName()];

src/Utils/Html.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static function el($name = NULL, $attrs = NULL)
7070

7171
if (isset($parts[1])) {
7272
foreach (Strings::matchAll($parts[1] . ' ', '#([a-z0-9:-]+)(?:=(["\'])?(.*?)(?(2)\\2|\s))?#i') as $m) {
73-
$el->attrs[$m[1]] = isset($m[3]) ? $m[3] : TRUE;
73+
$el->attrs[$m[1]] = $m[3] ?? TRUE;
7474
}
7575
}
7676

@@ -175,7 +175,7 @@ public function setAttribute($name, $value)
175175
*/
176176
public function getAttribute($name)
177177
{
178-
return isset($this->attrs[$name]) ? $this->attrs[$name] : NULL;
178+
return $this->attrs[$name] ?? NULL;
179179
}
180180

181181

@@ -249,7 +249,7 @@ public function __call($m, $args)
249249
$m = substr($m, 3);
250250
$m[0] = $m[0] | "\x20";
251251
if ($p === 'get') {
252-
return isset($this->attrs[$m]) ? $this->attrs[$m] : NULL;
252+
return $this->attrs[$m] ?? NULL;
253253

254254
} elseif ($p === 'add') {
255255
$args[] = TRUE;

src/Utils/Strings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ public static function pcre($func, $args)
592592
if (($code = preg_last_error()) // run-time error, but preg_last_error & return code are liars
593593
&& ($res === NULL || !in_array($func, ['preg_filter', 'preg_replace_callback', 'preg_replace']))
594594
) {
595-
throw new RegexpException((isset($messages[$code]) ? $messages[$code] : 'Unknown error')
595+
throw new RegexpException(($messages[$code] ?? 'Unknown error')
596596
. ' (pattern: ' . implode(' or ', (array) $args[0]) . ')', $code);
597597
}
598598
return $res;

src/Utils/Validators.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public static function is($value, $expected)
134134
continue;
135135
}
136136
} elseif ($type === 'pattern') {
137-
if (preg_match('|^' . (isset($item[1]) ? $item[1] : '') . '\z|', $value)) {
137+
if (preg_match('|^' . ($item[1] ?? '') . '\z|', $value)) {
138138
return TRUE;
139139
}
140140
continue;

0 commit comments

Comments
 (0)