File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,6 @@ public static function covertToArray(string $xml): array
2121 $ output = (array ) Helper::domNodeToArray ($ root );
2222 $ output ['@root ' ] = $ root ->tagName ;
2323
24- return $ output ?? [] ;
24+ return $ output ;
2525 }
2626}
Original file line number Diff line number Diff line change @@ -35,19 +35,21 @@ public static function domNodeToArray($node): mixed
3535 if (!isset ($ output [$ t ])) {
3636 $ output [$ t ] = [];
3737 }
38+ /** @phpstan-ignore-next-line */
3839 if (is_array ($ v ) && empty ($ v )) {
3940 $ v = '' ;
4041 }
4142 $ output [$ t ][] = $ v ;
43+ /** @phpstan-ignore-next-line */
4244 } elseif ($ v || $ v === '0 ' ) {
4345 $ output = (string ) $ v ;
4446 }
4547 }
46- if ($ node ->attributes ->length && !is_array ($ output )) { // has attributes but isn't an array
48+ if ($ node ->attributes ->length > 0 && !is_array ($ output )) { // has attributes but isn't an array
4749 $ output = ['@content ' => $ output ]; // change output into an array.
4850 }
4951 if (is_array ($ output )) {
50- if ($ node ->attributes ->length ) {
52+ if ($ node ->attributes ->length > 0 ) {
5153 $ a = [];
5254 foreach ($ node ->attributes as $ attrName => $ attrNode ) {
5355 $ a [$ attrName ] = (string ) $ attrNode ->value ;
You can’t perform that action at this time.
0 commit comments