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:
co-authored by
Claude Sonnet 5
parent
487176d345
commit
6f0e430804
@@ -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'))
|
||||
->flatMap(function (SplFileInfo $file) use ($names): array {
|
||||
// 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.
|
||||
$source = preg_replace(['/\{\{--.*?--\}\}/s', "/<<<'BLADE'.*?^\\s*BLADE,/sm"], '', $file->getContents());
|
||||
// are that usage; neither is compiled as the package's own markup. An example heredoc
|
||||
// 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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user