1515use App \Service \Toolkit \ToolkitService ;
1616use Symfony \Component \Filesystem \Filesystem ;
1717use Symfony \Component \Filesystem \Path ;
18- use Symfony \Component \String \AbstractString ;
1918use Symfony \UX \Toolkit \Recipe \Recipe ;
2019use 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