@@ -11,25 +11,25 @@ use function Markup\raw;
1111// --- scalar and array child coercion ---
1212
1313// Scalars: int/float stringify, true -> "1", false/null -> "".
14- echo (new Element ('p ' , [], [1 , ' ' , 2.5 , ' ' , true , false , null ]))->__toString (), "\n" ;
14+ echo (new Element ('p ' , [], [1 , ' ' , 2.5 , ' ' , true , false , null ]))->__toString (), PHP_EOL ;
1515
1616// Arrays flatten recursively (the array_map loop idiom).
1717$ items = ['Ada ' , 'Linus ' , 'Grace ' ];
1818echo (new Element ('ul ' , [], [
1919 array_map (fn ($ n ) => new Element ('li ' , [], [$ n ]), $ items ),
20- ]))->__toString (), "\n" ;
20+ ]))->__toString (), PHP_EOL ;
2121
2222// A nested Html passes through un-escaped.
23- echo (new Element ('div ' , [], [raw ('<b>bold</b> ' )]))->__toString (), "\n" ;
23+ echo (new Element ('div ' , [], [raw ('<b>bold</b> ' )]))->__toString (), PHP_EOL ;
2424
2525// Nested elements are Html too.
26- echo (new Element ('div ' , [], [new Element ('em ' , [], ['hi & bye ' ])]))->__toString (), "\n" ;
26+ echo (new Element ('div ' , [], [new Element ('em ' , [], ['hi & bye ' ])]))->__toString (), PHP_EOL ;
2727
2828// Non-Stringable object is a hard error.
2929try {
3030 (new Element ('div ' , [], [new stdClass ]))->__toString ();
3131} catch (\Throwable $ e ) {
32- echo $ e ::class, ': ' , $ e ->getMessage (), "\n" ;
32+ echo $ e ::class, ': ' , $ e ->getMessage (), PHP_EOL ;
3333}
3434
3535// --- Traversable children: generators, Iterator, IteratorAggregate ---
@@ -39,19 +39,19 @@ function rows(): Generator {
3939 yield new Element ('li ' , [], ['one ' ]);
4040 yield new Element ('li ' , [], ['two ' ]);
4141}
42- echo (new Element ('ul ' , [], [rows ()]))->__toString (), "\n" ;
42+ echo (new Element ('ul ' , [], [rows ()]))->__toString (), PHP_EOL ;
4343
4444// ArrayIterator (Iterator), mixing scalars and Html, with keys ignored
4545$ it = new ArrayIterator (['a ' => 'x & y ' , 'b ' => new Element ('b ' , [], ['z ' ])]);
46- echo (new Element ('p ' , [], [$ it ]))->__toString (), "\n" ;
46+ echo (new Element ('p ' , [], [$ it ]))->__toString (), PHP_EOL ;
4747
4848// IteratorAggregate, nested inside an array (recursive flattening)
4949$ agg = new class implements IteratorAggregate {
5050 public function getIterator (): Iterator {
5151 return new ArrayIterator ([new Element ('span ' , [], ['nested ' ])]);
5252 }
5353};
54- echo (new Element ('div ' , [], [['before ' , $ agg , ' after ' ]]))->__toString (), "\n" ;
54+ echo (new Element ('div ' , [], [['before ' , $ agg , ' after ' ]]))->__toString (), PHP_EOL ;
5555
5656// An exception thrown mid-iteration propagates.
5757function boom (): Generator {
@@ -61,7 +61,7 @@ function boom(): Generator {
6161try {
6262 (new Element ('div ' , [], [boom ()]))->__toString ();
6363} catch (\Throwable $ e ) {
64- echo $ e ::class, ': ' , $ e ->getMessage (), "\n" ;
64+ echo $ e ::class, ': ' , $ e ->getMessage (), PHP_EOL ;
6565}
6666
6767// --- nesting-depth bound ---
@@ -72,13 +72,13 @@ for ($i = 0; $i < 2048; $i++) {
7272 $ kids = [$ kids ];
7373}
7474try {
75- echo (new E ('div ' , [], $ kids ))->__toString (), "\n" ;
75+ echo (new E ('div ' , [], $ kids ))->__toString (), PHP_EOL ;
7676} catch (\Throwable $ e ) {
77- echo $ e ::class, ': ' , $ e ->getMessage (), "\n" ;
77+ echo $ e ::class, ': ' , $ e ->getMessage (), PHP_EOL ;
7878}
7979
8080// Normal (shallow) nesting still renders.
81- echo (new E ('ul ' , [], [[[new E ('li ' , [], ['ok ' ])]]]))->__toString (), "\n" ;
81+ echo (new E ('ul ' , [], [[[new E ('li ' , [], ['ok ' ])]]]))->__toString (), PHP_EOL ;
8282?>
8383--EXPECTF--
8484<p>1 2.5 1</p>
0 commit comments