Skip to content

Commit 496a5dc

Browse files
committed
utilization of operator ??
1 parent fd13d9f commit 496a5dc

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

Diff for: src/Utils/Callback.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public static function unwrap(\Closure $closure): callable
179179
$r = new \ReflectionFunction($closure);
180180
if (substr($r->getName(), -1) === '}') {
181181
$vars = $r->getStaticVariables();
182-
return isset($vars['_callable_']) ? $vars['_callable_'] : $closure;
182+
return $vars['_callable_'] ?? $closure;
183183

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

Diff for: src/Utils/Html.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static function el(string $name = NULL, $attrs = NULL): self
7272

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

@@ -177,7 +177,7 @@ public function setAttribute(string $name, $value)
177177
*/
178178
public function getAttribute(string $name)
179179
{
180-
return isset($this->attrs[$name]) ? $this->attrs[$name] : NULL;
180+
return $this->attrs[$name] ?? NULL;
181181
}
182182

183183

@@ -251,7 +251,7 @@ public function __call(string $m, array $args)
251251
$m = substr($m, 3);
252252
$m[0] = $m[0] | "\x20";
253253
if ($p === 'get') {
254-
return isset($this->attrs[$m]) ? $this->attrs[$m] : NULL;
254+
return $this->attrs[$m] ?? NULL;
255255

256256
} elseif ($p === 'add') {
257257
$args[] = TRUE;

Diff for: src/Utils/Strings.php

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

Diff for: src/Utils/Validators.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public static function is($value, string $expected): bool
136136
continue;
137137
}
138138
} elseif ($type === 'pattern') {
139-
if (preg_match('|^' . (isset($item[1]) ? $item[1] : '') . '\z|', $value)) {
139+
if (preg_match('|^' . ($item[1] ?? '') . '\z|', $value)) {
140140
return TRUE;
141141
}
142142
continue;

0 commit comments

Comments
 (0)