Skip to content

Commit 334deef

Browse files
committedMar 2, 2021
Change internal function calls
Changed: - Removed unnecessary call to `jsonSerialize()` method when directly used with `json_encode()` - Replaced `call_user_func()` with direct calling of `$callback`
1 parent 1a68b93 commit 334deef

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed
 

‎Function.HTML-Build-Attributes.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ function html_build_attributes($attr, callable $callback = null)
3838
if ($val instanceof Closure) {
3939
$val = $val();
4040
} elseif ($val instanceof JsonSerializable) {
41-
$val = json_encode(
42-
$val->jsonSerialize(),
43-
(JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE)
44-
);
41+
$val = json_encode($val, (JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE));
4542
} elseif (is_callable([ $val, 'toArray' ])) {
4643
$val = $val->toArray();
4744
} elseif (is_callable([ $val, '__toString' ])) {
@@ -68,7 +65,7 @@ function html_build_attributes($attr, callable $callback = null)
6865
}
6966

7067
if (is_callable($callback)) {
71-
$val = call_user_func($callback, $val);
68+
$val = $callback($val);
7269
} elseif (function_exists('esc_attr')) {
7370
$val = esc_attr($val);
7471
} else {

0 commit comments

Comments
 (0)
Please sign in to comment.