Recognise a semicolon-terminated example heredoc as documented usage

InternalComponentsTest strips a showcase example's <<<'BLADE' heredoc
before checking that a package view only ever refers to its own
components through the livewire-material:: namespace, since an
example heredoc documents an application's own (unprefixed) usage.
The check only recognised an array's BLADE, terminator; the Layout
section's three dedicated pages (plan step 38) assign their one
example to $code with BLADE; instead, which the check now strips too.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
This commit is contained in:
Andreas Reinhold / reini
2026-09-15 04:24:24 +02:00
co-authored by Claude Sonnet 5
parent 487176d345
commit 6f0e430804
+4 -2
View File
@@ -26,8 +26,10 @@ it('refers to its own components through its namespace, which no prefix or app c
->filter(fn (SplFileInfo $file): bool => str_ends_with($file->getFilename(), '.blade.php')) ->filter(fn (SplFileInfo $file): bool => str_ends_with($file->getFilename(), '.blade.php'))
->flatMap(function (SplFileInfo $file) use ($names): array { ->flatMap(function (SplFileInfo $file) use ($names): array {
// Comments document usage as an application writes it, and the showcase's examples // Comments document usage as an application writes it, and the showcase's examples
// are that usage; neither is compiled as the package's own markup. // are that usage; neither is compiled as the package's own markup. An example heredoc
$source = preg_replace(['/\{\{--.*?--\}\}/s', "/<<<'BLADE'.*?^\\s*BLADE,/sm"], '', $file->getContents()); // ends `BLADE,` as an array's value (most sections) or `BLADE;` assigned to its own
// variable (a Layout page with a single example of its own, plan step 38).
$source = preg_replace(['/\{\{--.*?--\}\}/s', "/<<<'BLADE'.*?^\\s*BLADE[,;]/sm"], '', $file->getContents());
preg_match_all('/<\/?x-('.$names.')(?=[\s\/>])/', $source, $matches); preg_match_all('/<\/?x-('.$names.')(?=[\s\/>])/', $source, $matches);