@@ -155,7 +155,7 @@ public function dumpScalar(Cursor $cursor, $type, $value)
155
155
156
156
$ this ->line .= $ this ->style ($ style , $ value , $ attr );
157
157
158
- $ this ->dumpLine ($ cursor-> depth , true );
158
+ $ this ->endValue ($ cursor );
159
159
}
160
160
161
161
/**
@@ -171,7 +171,7 @@ public function dumpString(Cursor $cursor, $str, $bin, $cut)
171
171
}
172
172
if ('' === $ str ) {
173
173
$ this ->line .= '"" ' ;
174
- $ this ->dumpLine ($ cursor-> depth , true );
174
+ $ this ->endValue ($ cursor );
175
175
} else {
176
176
$ attr += array (
177
177
'length ' => 0 <= $ cut ? mb_strlen ($ str , 'UTF-8 ' ) + $ cut : 0 ,
@@ -237,7 +237,11 @@ public function dumpString(Cursor $cursor, $str, $bin, $cut)
237
237
$ lineCut = 0 ;
238
238
}
239
239
240
- $ this ->dumpLine ($ cursor ->depth , $ i > $ m );
240
+ if ($ i > $ m ) {
241
+ $ this ->endValue ($ cursor );
242
+ } else {
243
+ $ this ->dumpLine ($ cursor ->depth );
244
+ }
241
245
}
242
246
}
243
247
}
@@ -280,7 +284,7 @@ public function leaveHash(Cursor $cursor, $type, $class, $hasChild, $cut)
280
284
{
281
285
$ this ->dumpEllipsis ($ cursor , $ hasChild , $ cut );
282
286
$ this ->line .= Cursor::HASH_OBJECT === $ type ? '} ' : (Cursor::HASH_RESOURCE !== $ type ? '] ' : ($ hasChild ? '} ' : '' ));
283
- $ this ->dumpLine ($ cursor-> depth , true );
287
+ $ this ->endValue ($ cursor );
284
288
}
285
289
286
290
/**
@@ -486,4 +490,15 @@ protected function dumpLine($depth, $endOfValue = false)
486
490
}
487
491
parent ::dumpLine ($ depth );
488
492
}
493
+
494
+ protected function endValue (Cursor $ cursor )
495
+ {
496
+ if (self ::DUMP_TRAILING_COMMA & $ this ->flags && $ cursor ->depth !== -0 ) {
497
+ $ this ->line .= ', ' ;
4
6164
98
+ } elseif (self ::DUMP_COMMA_SEPARATOR & $ this ->flags && 1 < $ cursor ->hashLength - $ cursor ->hashIndex ) {
499
+ $ this ->line .= ', ' ;
500
+ }
501
+
502
+ $ this ->dumpLine ($ cursor ->depth , true );
503
+ }
489
504
}
0 commit comments