Skip to content

Commit a49f0d5

Browse files
author
Nikhilesh Jasuja
committed
Make attribute sort stable across PHP versions
1 parent df08c27 commit a49f0d5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/JustHTML/Serialize.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ private static function attrsToTestFormat($node, int $indent): array
268268

269269
foreach ($node->attrs as $attrName => $attrValue) {
270270
$value = $attrValue ?? '';
271+
$attrName = (string)$attrName;
271272
$displayName = $attrName;
272273
if ($namespace !== null && $namespace !== 'html') {
273274
$lowerName = strtolower($attrName);
@@ -279,7 +280,7 @@ private static function attrsToTestFormat($node, int $indent): array
279280
}
280281

281282
usort($displayAttrs, static function ($a, $b) {
282-
return $a[0] <=> $b[0];
283+
return strcmp($a[0], $b[0]);
283284
});
284285

285286
foreach ($displayAttrs as [$displayName, $value]) {

0 commit comments

Comments
 (0)