Skip to content

Commit 4d3f91d

Browse files
committed
Replace "\n" with PHP_EOL
1 parent aa79823 commit 4d3f91d

19 files changed

Lines changed: 226 additions & 226 deletions

ext/markup/tests/children.phpt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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'];
1818
echo (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.
2929
try {
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.
5757
function boom(): Generator {
@@ -61,7 +61,7 @@ function boom(): Generator {
6161
try {
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
}
7474
try {
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>

ext/markup/tests/component_hardening.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function expect_error(callable $f): void {
1111
$f();
1212
echo "NO ERROR\n";
1313
} catch (Error $e) {
14-
echo $e::class, ": ", $e->getMessage(), "\n";
14+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
1515
}
1616
}
1717

@@ -49,7 +49,7 @@ class NoCtor implements Markup\Html {
4949
public function toHtml(): Markup\Html { return Markup\raw("no-ctor"); }
5050
}
5151
expect_error(fn() => render_component("NoCtor", ["title" => "x"]));
52-
echo render_component("NoCtor"), "\n"; // without props it is fine
52+
echo render_component("NoCtor"), PHP_EOL; // without props it is fine
5353

5454
// --- static-method visibility guards ---
5555

@@ -75,7 +75,7 @@ for ($i = 0; $i < 3; $i++) {
7575
try {
7676
echo render_component('NeedsDep')->__toString();
7777
} catch (\Error $e) {
78-
echo $e->getMessage(), "\n";
78+
echo $e->getMessage(), PHP_EOL;
7979
}
8080
}
8181

@@ -87,7 +87,7 @@ class Boom implements Markup\Html {
8787
try {
8888
echo render_component('Boom')->__toString();
8989
} catch (\Throwable $e) {
90-
echo $e::class, ": ", $e->getMessage(), "\n";
90+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
9191
}
9292

9393
echo "clean\n";

ext/markup/tests/component_hooks.phpt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,30 +64,30 @@ $make = fn(string $class, array $args)
6464

6565
// (1) Without hooks, the engine's own `new` runs and fails for the missing Clock.
6666
try { echo <TimeBadge label="x"/>; }
67-
catch (\Error $e) { echo "default: ", $e->getMessage(), "\n"; }
67+
catch (\Error $e) { echo "default: ", $e->getMessage(), PHP_EOL; }
6868

6969
// $defer is first, so a working result proves the chain skips a null-returning
7070
// factory and falls through to $make.
7171
register_component_factory($defer);
7272
register_component_factory($make);
7373

74-
echo "class: ", <TimeBadge label="A"/>, "\n";
74+
echo "class: ", <TimeBadge label="A"/>, PHP_EOL;
7575

7676
// (2) A factory must return an instance of the requested class. Swap $make for a
7777
// bad factory so the chain becomes [$defer, $bad] and the bad one is reached.
7878
var_dump(unregister_component_factory($make));
7979
$bad = fn(string $class, array $args) => new Clock();
8080
register_component_factory($bad);
8181
try { echo <TimeBadge label="e"/>; }
82-
catch (\Error $e) { echo "badreturn: ", $e->getMessage(), "\n"; }
82+
catch (\Error $e) { echo "badreturn: ", $e->getMessage(), PHP_EOL; }
8383

8484
// (3) Unregistering everything restores the engine default. Unregister identity
8585
// is by callable; a fresh closure does not match.
8686
var_dump(unregister_component_factory(fn($c, $a) => null));
8787
var_dump(unregister_component_factory($defer));
8888
var_dump(unregister_component_factory($bad));
8989
try { echo <TimeBadge label="f"/>; }
90-
catch (\Error $e) { echo "restored: ", $e->getMessage(), "\n"; }
90+
catch (\Error $e) { echo "restored: ", $e->getMessage(), PHP_EOL; }
9191

9292
// --- decorators: uniform wrapping, composition, bad return ---
9393

@@ -96,20 +96,20 @@ catch (\Error $e) { echo "restored: ", $e->getMessage(), "\n"; }
9696
$marker = fn(Markup\Html $h, string $c) => Markup\raw("[$c]" . $h . "[/$c]");
9797
register_component_decorator($marker);
9898

99-
echo <Card title="a"/>, "\n";
100-
echo <Note t="b"/>, "\n";
101-
echo <Author::byline t="c"/>, "\n";
99+
echo <Card title="a"/>, PHP_EOL;
100+
echo <Note t="b"/>, PHP_EOL;
101+
echo <Author::byline t="c"/>, PHP_EOL;
102102

103103
// Decorators compose in registration order, each wrapping the previous result.
104104
$outer = fn(Markup\Html $h, string $c) => Markup\raw("<<" . $h . ">>");
105105
register_component_decorator($outer);
106-
echo <Note t="d"/>, "\n";
106+
echo <Note t="d"/>, PHP_EOL;
107107

108108
// A decorator must return a Markup\Html.
109109
$badDecorator = fn(Markup\Html $h, string $c) => "not html";
110110
register_component_decorator($badDecorator);
111111
try { echo <Note t="e"/>; }
112-
catch (\Error $e) { echo $e->getMessage(), "\n"; }
112+
catch (\Error $e) { echo $e->getMessage(), PHP_EOL; }
113113

114114
// Clean up this section's decorators so the next section starts from default.
115115
unregister_component_decorator($badDecorator);
@@ -126,8 +126,8 @@ $cardFactory = function (string $class, array $args) {
126126
return new Card("made");
127127
};
128128
register_component_factory($cardFactory, '\cArD');
129-
echo <Card/>, "\n";
130-
echo <Badge/>, "\n";
129+
echo <Card/>, PHP_EOL;
130+
echo <Badge/>, PHP_EOL;
131131

132132
// (2) Scoped and unscoped factories share one chain in registration order:
133133
// the scoped one (registered first) wins for Card; the unscoped one sees Badge.
@@ -136,25 +136,25 @@ $anyFactory = function (string $class, array $args) {
136136
return null; // defer
137137
};
138138
register_component_factory($anyFactory);
139-
echo <Card/>, "\n";
140-
echo <Badge/>, "\n";
139+
echo <Card/>, PHP_EOL;
140+
echo <Badge/>, PHP_EOL;
141141

142142
// (3) Unregister identity includes the scope: the callable alone (or with the
143143
// wrong scope) does not match; with its scope it does.
144144
var_dump(unregister_component_factory($cardFactory));
145145
var_dump(unregister_component_factory($cardFactory, 'Badge'));
146146
var_dump(unregister_component_factory($cardFactory, 'Card'));
147147
var_dump(unregister_component_factory($anyFactory));
148-
echo <Card/>, "\n";
148+
echo <Card/>, PHP_EOL;
149149

150150
// (4) A decorator scoped to Badge wraps only Badge's output - Card renders
151151
// untouched.
152152
$badgeDecorator = fn(Markup\Html $h, string $c) => Markup\raw("<<$h>>");
153153
register_component_decorator($badgeDecorator, Badge::class);
154-
echo <Badge label="B"/>, "\n";
155-
echo <Card title="C"/>, "\n";
154+
echo <Badge label="B"/>, PHP_EOL;
155+
echo <Card title="C"/>, PHP_EOL;
156156
var_dump(unregister_component_decorator($badgeDecorator, 'badge'));
157-
echo <Badge label="B"/>, "\n";
157+
echo <Badge label="B"/>, PHP_EOL;
158158
?>
159159
--EXPECT--
160160
default: TimeBadge::__construct(): Argument #1 ($clock) not passed

ext/markup/tests/component_slots.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ $out = render_component(
3939
],
4040
new Fragment([new E('p', [], ['loose body'])]), // body slot
4141
);
42-
echo $out, "\n";
42+
echo $out, PHP_EOL;
4343

4444
// Body slot only.
4545
class Panel implements Markup\Html {
@@ -51,7 +51,7 @@ class Panel implements Markup\Html {
5151
return new E('section', ['class' => $this->kind], [$this->content]);
5252
}
5353
}
54-
echo render_component(Panel::class, ['kind' => 'note'], new Fragment([Markup\raw('<b>hi</b>')]))->__toString(), "\n";
54+
echo render_component(Panel::class, ['kind' => 'note'], new Fragment([Markup\raw('<b>hi</b>')]))->__toString(), PHP_EOL;
5555

5656
// --- slot-routing validation errors ---
5757

@@ -60,29 +60,29 @@ class Solo implements Markup\Html {
6060
public function __construct(#[Slot] public Markup\Html $body) {}
6161
public function toHtml(): Markup\Html { return new E('p', [], [$this->body]); }
6262
}
63-
echo err(fn() => render_component(Solo::class, ['body' => 'x'], new Fragment([Markup\raw('y')]))), "\n";
63+
echo err(fn() => render_component(Solo::class, ['body' => 'x'], new Fragment([Markup\raw('y')]))), PHP_EOL;
6464

6565
// Body content given to a component that has no slot parameter.
6666
class NoSlot implements Markup\Html {
6767
public function __construct(public string $x) {}
6868
public function toHtml(): Markup\Html { return new E('i', [], [$this->x]); }
6969
}
70-
echo err(fn() => render_component(NoSlot::class, ['x' => 'hi'], new Fragment([Markup\raw('body')]))), "\n";
70+
echo err(fn() => render_component(NoSlot::class, ['x' => 'hi'], new Fragment([Markup\raw('body')]))), PHP_EOL;
7171

7272
// More than one slot parameter is a definition error.
7373
class TwoSlots implements Markup\Html {
7474
public function __construct(#[Slot] public ?Markup\Html $a = null, #[Slot] public ?Markup\Html $b = null) {}
7575
public function toHtml(): Markup\Html { return new Fragment([$this->a, $this->b]); }
7676
}
77-
echo err(fn() => render_component(TwoSlots::class, [], new Fragment([]))), "\n";
77+
echo err(fn() => render_component(TwoSlots::class, [], new Fragment([]))), PHP_EOL;
7878

7979
// #[Slot] on a variadic parameter is a definition error.
8080
class Variadic implements Markup\Html {
8181
private array $parts;
8282
public function __construct(#[Slot] Markup\Html ...$parts) { $this->parts = $parts; }
8383
public function toHtml(): Markup\Html { return new Fragment($this->parts); }
8484
}
85-
echo err(fn() => render_component(Variadic::class, [], new Fragment([]))), "\n";
85+
echo err(fn() => render_component(Variadic::class, [], new Fragment([]))), PHP_EOL;
8686

8787
// --- Markup\Slot is a bare parameter-target marker attribute ---
8888

ext/markup/tests/components.phpt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,49 +48,49 @@ class Author {
4848
$who = 'Ada & co';
4949

5050
// class component: attribute prop + body routed to the anonymous slot
51-
echo (<Card title={$who}><p>Hi {$who}</p></Card>)->__toString(), "\n";
51+
echo (<Card title={$who}><p>Hi {$who}</p></Card>)->__toString(), PHP_EOL;
5252

5353
// self-closing class component (no body -> slot is null)
54-
echo (<Card title="Solo"/>)->__toString(), "\n";
54+
echo (<Card title="Solo"/>)->__toString(), PHP_EOL;
5555

5656
// static-method component
57-
echo (<Author::byline name={$who}/>)->__toString(), "\n";
57+
echo (<Author::byline name={$who}/>)->__toString(), PHP_EOL;
5858

5959
// the same dispatch, called directly by name
60-
echo render_component(Badge::class, ['label' => 'New &'])->__toString(), "\n";
60+
echo render_component(Badge::class, ['label' => 'New &'])->__toString(), PHP_EOL;
6161

6262
// a component used as a child of an HTML element, and inside interpolation
63-
echo (<div class="wrap"><Badge label="x"/></div>)->__toString(), "\n";
64-
echo (<ul>{array_map(fn($t) => <Badge label={$t}/>, ['a', 'b'])}</ul>)->__toString(), "\n";
63+
echo (<div class="wrap"><Badge label="x"/></div>)->__toString(), PHP_EOL;
64+
echo (<ul>{array_map(fn($t) => <Badge label={$t}/>, ['a', 'b'])}</ul>)->__toString(), PHP_EOL;
6565

6666
// --- resolution errors: a component is a class implementing Html ---
6767

6868
// Unknown symbol -> hard error.
69-
echo err(fn() => render_component('NoSuchThing')), "\n";
69+
echo err(fn() => render_component('NoSuchThing')), PHP_EOL;
7070

7171
// A function name is not a component (functions are Future Scope).
7272
function Chip(): Markup\Html { return Markup\raw('FROM FUNCTION'); }
73-
echo err(fn() => render_component('Chip')), "\n";
73+
echo err(fn() => render_component('Chip')), PHP_EOL;
7474

7575
// A "date"-named tag can never reach the internal date() function.
76-
echo err(fn() => render_component('date', ['datetime' => 'now'])), "\n";
76+
echo err(fn() => render_component('date', ['datetime' => 'now'])), PHP_EOL;
7777

7878
// A class that does NOT implement Html -> hard error.
7979
class Plain {}
80-
echo err(fn() => render_component('Plain')), "\n";
80+
echo err(fn() => render_component('Plain')), PHP_EOL;
8181

8282
// "Class::method" resolves to a public static method and is called; the
8383
// result must be a Markup\Html.
84-
echo render_component('Author::byline', ['name' => 'Ada'])->__toString(), "\n";
85-
echo err(fn() => render_component('Author::broken')), "\n";
86-
echo err(fn() => render_component('NoSuchClass::method')), "\n";
84+
echo render_component('Author::byline', ['name' => 'Ada'])->__toString(), PHP_EOL;
85+
echo err(fn() => render_component('Author::broken')), PHP_EOL;
86+
echo err(fn() => render_component('NoSuchClass::method')), PHP_EOL;
8787

8888
// A class implementing Html resolves, regardless of same-named functions.
8989
function Widget(): Markup\Html { return Markup\raw('FROM FUNCTION'); }
9090
class Widget implements Markup\Html {
9191
public function toHtml(): Markup\Html { return Markup\raw('FROM CLASS'); }
9292
}
93-
echo render_component('Widget')->__toString(), "\n";
93+
echo render_component('Widget')->__toString(), PHP_EOL;
9494

9595
// --- hyphenated attributes route through named args ---
9696

@@ -105,14 +105,14 @@ class Box implements Markup\Html {
105105

106106
// Hyphenated attributes work directly on a component (no spread needed) - they
107107
// become named arguments and the variadic collects them.
108-
echo (<Box kind="note" data-id="7" aria-label="hi"/>), "\n";
108+
echo (<Box kind="note" data-id="7" aria-label="hi"/>), PHP_EOL;
109109

110110
// A component without a variadic rejects an unknown (hyphenated) attribute.
111111
class Tight implements Markup\Html {
112112
public function __construct(public string $kind) {}
113113
public function toHtml(): Markup\Html { return new E('div', ['class' => $this->kind], ['y']); }
114114
}
115-
echo err(fn() => (<Tight kind="b" data-x="1"/>)->__toString()), "\n";
115+
echo err(fn() => (<Tight kind="b" data-x="1"/>)->__toString()), PHP_EOL;
116116
?>
117117
--EXPECT--
118118
<section class="card"><h2>Ada &amp; co</h2><p>Hi Ada &amp; co</p></section>

0 commit comments

Comments
 (0)