@@ -381,6 +381,7 @@ public static function aList($data, $title = null, array $opts = [])
381381 'keyMinWidth ' => 8 ,
382382 'titleStyle ' => 'comment ' ,
383383 'returned ' => false ,
384+ 'lastNewline ' => true ,
384385 ], $ opts );
385386
386387 // title
@@ -396,7 +397,7 @@ public static function aList($data, $title = null, array $opts = [])
396397 return $ string ;
397398 }
398399
399- return self ::write ($ string );
400+ return self ::write ($ string, $ opts [ ' lastNewline ' ] );
400401 }
401402
402403 /**
@@ -441,6 +442,12 @@ public static function mList(array $data, array $opts = [])
441442 $ buffer = [];
442443 $ opts ['returned ' ] = true ;
443444 $ ignoreEmpty = $ opts ['ignoreEmpty ' ] ?? true ;
445+ $ lastNewline = true ;
446+
447+ if (isset ($ opts ['lastNewline ' ])) {
448+ $ lastNewline = $ opts ['lastNewline ' ];
449+ unset($ opts ['lastNewline ' ]);
450+ }
444451
445452 foreach ($ data as $ title => $ list ) {
446453 if ($ ignoreEmpty && !$ list ) {
@@ -450,7 +457,7 @@ public static function mList(array $data, array $opts = [])
450457 $ buffer [] = self ::aList ($ list , $ title , $ opts );
451458 }
452459
453- self ::write (implode ("\n" , $ buffer ), $ opts [ ' lastNewline ' ] ?? true );
460+ self ::write (implode ("\n" , $ buffer ), $ lastNewline );
454461 }
455462
456463 /**
0 commit comments