@@ -399,7 +399,7 @@ protected function fixLinesForNoClosure(array &$lines, array $closures): void
399
399
}
400
400
401
401
/**
402
- * Move boundary newline chars in parts to be extra new parts.
402
+ * Extract boundary newlines from parts into new parts.
403
403
*
404
404
* @param array[] $parts the parts
405
405
* @param string[] $closures the closures
@@ -414,10 +414,11 @@ protected function revisePartsForBoundaryNewlines(array &$parts, array $closures
414
414
for ($ i = \count ($ parts ) - 1 ; $ i >= 0 ; --$ i ) {
415
415
$ part = &$ parts [$ i ];
416
416
417
+ // deal with leading newlines
417
418
$ part ['content ' ] = \preg_replace_callback (
418
419
"/(?P<closure> {$ closureRegexL })(?P<nl>[ \r\n]++)/u " ,
419
420
function (array $ matches ) use (&$ parts , $ part , $ closures ): string {
420
- // add a new part for the extract newline chars
421
+ // add a new part for the extracted newlines
421
422
$ part ['order ' ] = -1 ;
422
423
$ part ['content ' ] = "{$ closures [0 ]}{$ matches ['nl ' ]}{$ closures [1 ]}" ;
423
424
$ parts [] = $ part ;
@@ -427,10 +428,11 @@ function (array $matches) use (&$parts, $part, $closures): string {
427
428
$ part ['content ' ]
428
429
);
429
430
431
+ // deal with trailing newlines
430
432
$ part ['content ' ] = \preg_replace_callback (
431
433
"/(?P<nl>[ \r\n]++)(?P<closure> {$ closureRegexR })/u " ,
432
434
function (array $ matches ) use (&$ parts , $ part , $ closures ): string {
433
- // add a new part for the extract newline chars
435
+ // add a new part for the extracted newlines
434
436
$ part ['order ' ] = 1 ;
435
437
$ part ['content ' ] = "{$ closures [0 ]}{$ matches ['nl ' ]}{$ closures [1 ]}" ;
436
438
$ parts [] = $ part ;
0 commit comments