Skip to content

Commit 0667e88

Browse files
committed
feat: update fqcn parsing to reflect new package structure
1 parent c1cfce9 commit 0667e88

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/Markdown/Symbols/AttributeParser.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
use League\CommonMark\Parser\Inline\InlineParserInterface;
88
use League\CommonMark\Parser\Inline\InlineParserMatch;
99
use League\CommonMark\Parser\InlineParserContext;
10+
use Tempest\Support\Str;
1011

1112
use function Tempest\Support\str;
12-
use function Tempest\Support\Str\class_basename;
13-
use function Tempest\Support\Str\strip_start;
1413

1514
final readonly class AttributeParser implements InlineParserInterface
1615
{
@@ -35,7 +34,7 @@ public function parse(InlineParserContext $inlineContext): bool
3534
[$flag, $fqcn] = $inlineContext->getSubMatches();
3635
$url = str($fqcn)
3736
->stripStart(['\\Tempest\\', 'Tempest\\'])
38-
->replaceRegex("/^(\w+)/", 'src/Tempest/$0/src')
37+
->replaceRegex("/^(\w+)/", fn (array $matches) => sprintf("packages/%s/src", Str\to_kebab_case($matches[0])))
3938
->replace('\\', '/')
4039
->prepend('https://github.com/tempestphp/tempest-framework/blob/main/')
4140
->append('.php');

src/Markdown/Symbols/FqcnParser.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
use League\CommonMark\Parser\Inline\InlineParserInterface;
88
use League\CommonMark\Parser\Inline\InlineParserMatch;
99
use League\CommonMark\Parser\InlineParserContext;
10+
use Tempest\Support\Str;
1011

1112
use function Tempest\Support\str;
12-
use function Tempest\Support\Str\class_basename;
13-
use function Tempest\Support\Str\strip_start;
1413

1514
final readonly class FqcnParser implements InlineParserInterface
1615
{
@@ -35,13 +34,13 @@ public function parse(InlineParserContext $inlineContext): bool
3534
[$flag, $fqcn] = $inlineContext->getSubMatches();
3635
$url = str($fqcn)
3736
->stripStart(['\\Tempest\\', 'Tempest\\'])
38-
->replaceRegex("/^(\w+)/", 'src/Tempest/$0/src')
37+
->replaceRegex("/^(\w+)/", fn (array $matches) => sprintf("packages/%s/src", Str\to_kebab_case($matches[0])))
3938
->replace('\\', '/')
4039
->prepend('https://github.com/tempestphp/tempest-framework/blob/main/')
4140
->append('.php');
4241

4342
$link = new Link($url);
44-
$link->appendChild(new Code($flag === 'b' ? class_basename($fqcn) : strip_start($fqcn, '\\')));
43+
$link->appendChild(new Code($flag === 'b' ? Str\class_basename($fqcn) : Str\strip_start($fqcn, '\\')));
4544
$inlineContext->getContainer()->appendChild($link);
4645

4746
return true;

0 commit comments

Comments
 (0)