@@ -307,12 +307,14 @@ public function wrap($start, $maybeString, $end = '')
307
307
*/
308
308
public function block ($ array )
309
309
{
310
- return $ array && $ this ->length ($ array ) ? $ this ->indent ("{ \n" . $ this ->join ($ array , "\n" )) . "\n} " : '{} ' ;
310
+ return ($ array && $ this ->length ($ array ))
311
+ ? "{ \n" . $ this ->indent ($ this ->join ($ array , "\n" )) . "\n} "
312
+ : '{} ' ;
311
313
}
312
314
313
315
public function indent ($ maybeString )
314
316
{
315
- return $ maybeString ? str_replace ("\n" , "\n " , $ maybeString ) : '' ;
317
+ return $ maybeString ? ' ' . str_replace ("\n" , "\n " , $ maybeString ) : '' ;
316
318
}
317
319
318
320
public function manyList ($ start , $ list , $ separator , $ end )
@@ -344,12 +346,9 @@ function($x) { return !!$x;}
344
346
* a single-line, adding a leading blank line would strip that whitespace.
345
347
*/
346
348
private function printBlockString ($ value , $ isDescription ) {
349
+ $ escaped = str_replace ('""" ' , '\\""" ' , $ value );
347
350
return (($ value [0 ] === ' ' || $ value [0 ] === "\t" ) && strpos ($ value , "\n" ) === false )
348
- ? ('""" ' . str_replace ('""" ' , '\\""" ' , $ value ) . '""" ' )
349
- : (
350
- $ isDescription
351
- ? ("\"\"\"\n" . str_replace ('""" ' , '\\""" ' , $ value ) . "\n\"\"\"" )
352
- : ($ this ->indent ("\"\"\"\n" . str_replace ('""" ' , '\\""" ' , $ value )) . "\n\"\"\"" )
353
- );
351
+ ? ('""" ' . preg_replace ('/"$/ ' , "\"\n" , $ escaped ) . '""" ' )
352
+ : ("\"\"\"\n" . ($ isDescription ? $ escaped : $ this ->indent ($ escaped )) . "\n\"\"\"" );
354
353
}
355
354
}
0 commit comments