diff --git a/src/Utils/Callback.php b/src/Utils/Callback.php index e276804da..c11db923b 100644 --- a/src/Utils/Callback.php +++ b/src/Utils/Callback.php @@ -179,7 +179,7 @@ public static function unwrap(\Closure $closure): callable $r = new \ReflectionFunction($closure); if (substr($r->getName(), -1) === '}') { $vars = $r->getStaticVariables(); - return isset($vars['_callable_']) ? $vars['_callable_'] : $closure; + return $vars['_callable_'] ?? $closure; } elseif ($obj = $r->getClosureThis()) { return [$obj, $r->getName()]; diff --git a/src/Utils/Html.php b/src/Utils/Html.php index 59b54769c..008e5b5a0 100644 --- a/src/Utils/Html.php +++ b/src/Utils/Html.php @@ -72,7 +72,7 @@ public static function el(string $name = NULL, $attrs = NULL): self if (isset($parts[1])) { foreach (Strings::matchAll($parts[1] . ' ', '#([a-z0-9:-]+)(?:=(["\'])?(.*?)(?(2)\\2|\s))?#i') as $m) { - $el->attrs[$m[1]] = isset($m[3]) ? $m[3] : TRUE; + $el->attrs[$m[1]] = $m[3] ?? TRUE; } } @@ -177,7 +177,7 @@ public function setAttribute(string $name, $value) */ public function getAttribute(string $name) { - return isset($this->attrs[$name]) ? $this->attrs[$name] : NULL; + return $this->attrs[$name] ?? NULL; } @@ -251,7 +251,7 @@ public function __call(string $m, array $args) $m = substr($m, 3); $m[0] = $m[0] | "\x20"; if ($p === 'get') { - return isset($this->attrs[$m]) ? $this->attrs[$m] : NULL; + return $this->attrs[$m] ?? NULL; } elseif ($p === 'add') { $args[] = TRUE; diff --git a/src/Utils/Strings.php b/src/Utils/Strings.php index 7d9160e5f..4f9f53f31 100644 --- a/src/Utils/Strings.php +++ b/src/Utils/Strings.php @@ -594,7 +594,7 @@ public static function pcre(string $func, array $args) if (($code = preg_last_error()) // run-time error, but preg_last_error & return code are liars && ($res === NULL || !in_array($func, ['preg_filter', 'preg_replace_callback', 'preg_replace'])) ) { - throw new RegexpException((isset($messages[$code]) ? $messages[$code] : 'Unknown error') + throw new RegexpException(($messages[$code] ?? 'Unknown error') . ' (pattern: ' . implode(' or ', (array) $args[0]) . ')', $code); } return $res; diff --git a/src/Utils/Validators.php b/src/Utils/Validators.php index a4372d189..f845298e3 100644 --- a/src/Utils/Validators.php +++ b/src/Utils/Validators.php @@ -136,7 +136,7 @@ public static function is($value, string $expected): bool continue; } } elseif ($type === 'pattern') { - if (preg_match('|^' . (isset($item[1]) ? $item[1] : '') . '\z|', $value)) { + if (preg_match('|^' . ($item[1] ?? '') . '\z|', $value)) { return TRUE; } continue;