Skip to content

Commit d5fbdad

Browse files
committed
iterate
1 parent 57fc7bf commit d5fbdad

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

ux.symfony.com/src/Service/Toolkit/ToolkitService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function renderInstallationSteps(ToolkitKitId $kitId, Recipe $component):
104104
if ($phpPackageDependencies = $pool->getPhpPackageDependencies()) {
105105
$manual .= '<li><strong>If necessary, install the following Composer dependencies:</strong>';
106106
$manual .= CodeBlockRenderer::highlightCode('shell', '$ composer require '.implode(' ',
107-
array_map(fn(PhpPackageDependency $dependency) => $dependency->name.($dependency->constraintVersion ? ':'.$dependency->constraintVersion : ''), $phpPackageDependencies),
107+
array_map(fn (PhpPackageDependency $dependency) => $dependency->name.($dependency->constraintVersion ? ':'.$dependency->constraintVersion : ''), $phpPackageDependencies),
108108
), 'margin-bottom: 0');
109109
$manual .= '</li>';
110110
}

ux.symfony.com/src/Twig/Components/Toolkit/ComponentDoc.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use App\Service\Toolkit\ToolkitService;
1616
use Symfony\Component\Filesystem\Filesystem;
1717
use Symfony\Component\Filesystem\Path;
18-
use Symfony\Component\String\AbstractString;
1918
use Symfony\UX\Toolkit\Recipe\Recipe;
2019
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
2120

@@ -29,15 +28,15 @@ class ComponentDoc
2928

3029
public function __construct(
3130
private readonly Filesystem $filesystem,
32-
private readonly ToolkitService $toolkitService
31+
private readonly ToolkitService $toolkitService,
3332
) {
3433
}
3534

3635
public function getContent(): string
3736
{
3837
$examples = $this->getExamples();
3938

40-
return $this->adaptPreviewableCodeBlocks(sprintf(<<<MARKDOWN
39+
return $this->adaptPreviewableCodeBlocks(\sprintf(<<<MARKDOWN
4140
# %s
4241
4342
%s
@@ -60,9 +59,9 @@ public function getContent(): string
6059
$this->component->manifest->description,
6160
current($examples),
6261
$this->toolkitService->renderInstallationSteps($this->kitId, $this->component),
63-
dump(preg_replace('/^```twig.*\n/', '```twig'.PHP_EOL, current($examples))),
62+
dump(preg_replace('/^```twig.*\n/', '```twig'.\PHP_EOL, current($examples))),
6463
array_reduce(array_keys($examples), function (string $acc, string $exampleTitle) use ($examples) {
65-
$acc .= '### '.$exampleTitle.PHP_EOL.$examples[$exampleTitle].PHP_EOL;
64+
$acc .= '### '.$exampleTitle.\PHP_EOL.$examples[$exampleTitle].\PHP_EOL;
6665

6766
return $acc;
6867
}, '')
@@ -83,19 +82,19 @@ private function getExamples(): array
8382

8483
// Split the markdown for each title and content
8584
$examples = [];
86-
foreach (explode(PHP_EOL, $markdown) as $line) {
85+
foreach (explode(\PHP_EOL, $markdown) as $line) {
8786
if (str_starts_with($line, '## ')) {
8887
// This is a new example title
8988
$title = trim(substr($line, 2));
9089
$examples[$title] = '';
9190
} elseif (isset($title)) {
9291
// This line belongs to the last example
93-
$examples[$title] .= $line.PHP_EOL;
92+
$examples[$title] .= $line.\PHP_EOL;
9493
}
9594
}
9695

9796
if ([] === $examples) {
98-
throw new \LogicException(sprintf('No examples found in "%s".', $examplesMdPath));
97+
throw new \LogicException(\sprintf('No examples found in "%s".', $examplesMdPath));
9998
}
10099

101100
foreach ($examples as $title => &$example) {
@@ -118,7 +117,7 @@ private function adaptPreviewableCodeBlocks(string $markdownContent): string
118117
$options['kit'] = $this->kitId->value;
119118
}
120119

121-
return \sprintf('```%s %s'.PHP_EOL, $lang, json_encode($options, \JSON_THROW_ON_ERROR));
120+
return \sprintf('```%s %s'.\PHP_EOL, $lang, json_encode($options, \JSON_THROW_ON_ERROR));
122121
})->toString();
123122
}
124123
}

0 commit comments

Comments
 (0)