Skip to content

Commit 3ea6c28

Browse files
committed
iterate
1 parent 46689fe commit 3ea6c28

File tree

11 files changed

+23
-64
lines changed

11 files changed

+23
-64
lines changed

src/Toolkit/schema-kit-recipe-v1.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@
3232
"items": {
3333
"oneOf": [
3434
{
35+
"description": "A dependency on a PHP package",
3536
"type": "object",
3637
"required": ["type", "package"],
3738
"properties": {
3839
"type": {
3940
"type": "string",
40-
"enum": ["php"],
41-
"description": "PHP package dependency"
41+
"enum": ["php"]
4242
},
4343
"package": {
4444
"type": "string",
45-
"description": "Package name and optional version constraint"
45+
"description": "Package name and optional version constraint (e.g., 'vendor/package:^1.0')"
4646
}
4747
}
4848
}

src/Toolkit/src/Dependency/PhpPackageDependency.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ public function isHigherThan(self $dependency): bool
5252

5353
public function __toString(): string
5454
{
55-
return sprintf('PHP package "%s%s"', $this->name, null !== $this->constraintVersion ? ':'.$this->constraintVersion : '');
55+
return \sprintf('PHP package "%s%s"', $this->name, null !== $this->constraintVersion ? ':'.$this->constraintVersion : '');
5656
}
5757
}

src/Toolkit/src/Dependency/RecipeDependency.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ class RecipeDependency implements DependencyInterface
1818
*/
1919
public function __construct(
2020
public readonly string $name,
21-
)
22-
{
21+
) {
2322
}
2423

25-
2624
public function isEquivalentTo(DependencyInterface $dependency): bool
2725
{
2826
if (!$dependency instanceof self) {
@@ -34,6 +32,6 @@ public function isEquivalentTo(DependencyInterface $dependency): bool
3432

3533
public function __toString(): string
3634
{
37-
return sprintf('Recipe "%s"', $this->name);
35+
return \sprintf('Recipe "%s"', $this->name);
3836
}
3937
}

src/Toolkit/src/File/File.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
final class File implements \Stringable
2222
{
2323
/**
24-
* @param non-empty-string $relativePathName relative path from the kit root directory, example "templates/components/Table/Body.html.twig"
25-
*
2624
* @throws \InvalidArgumentException
2725
*/
2826
public function __construct(

src/Toolkit/src/File/FileToCopy.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/Toolkit/src/Kit/Kit.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
namespace Symfony\UX\Toolkit\Kit;
1313

1414
use Symfony\Component\Filesystem\Path;
15-
use Symfony\UX\Toolkit\Assert;
16-
use Symfony\UX\Toolkit\Asset\Component;
17-
use Symfony\UX\Toolkit\Asset\StimulusController;
1815
use Symfony\UX\Toolkit\Recipe\Recipe;
1916
use Symfony\UX\Toolkit\Recipe\RecipeType;
2017

@@ -31,13 +28,14 @@ final class Kit
3128
private array $recipes = [];
3229

3330
/**
34-
* @param non-empty-string $absolutePath
31+
* @param non-empty-string $absolutePath
32+
*
3533
* @throws \InvalidArgumentException
3634
*/
3735
public function __construct(
38-
public readonly string $absolutePath,
36+
public readonly string $absolutePath,
3937
public readonly KitManifest $manifest,
40-
public ?string $installAsMarkdown = null,
38+
public ?string $installAsMarkdown = null,
4139
) {
4240
if (!Path::isAbsolute($this->absolutePath)) {
4341
throw new \InvalidArgumentException(\sprintf('Kit path "%s" is not absolute.', $this->absolutePath));
@@ -58,7 +56,7 @@ public function addRecipe(Recipe $recipe): void
5856
/**
5957
* @return array<Recipe>
6058
*/
61-
public function getRecipes(RecipeType|null $ofType = null): array
59+
public function getRecipes(?RecipeType $ofType = null): array
6260
{
6361
if (null !== $ofType) {
6462
$this->recipes = array_filter($this->recipes, fn (Recipe $recipe) => $recipe->manifest->type === $ofType);

src/Toolkit/src/Kit/KitManifest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct(
2020
public readonly string $description,
2121
public readonly string $license,
2222
public readonly string $homepage,
23-
){
23+
) {
2424
Assert::kitName($this->name);
2525

2626
if (!filter_var($this->homepage, \FILTER_VALIDATE_URL)) {
@@ -34,7 +34,7 @@ public function __construct(
3434
*/
3535
public static function fromJson(string $json): self
3636
{
37-
$data = json_decode($json, true, flags: JSON_THROW_ON_ERROR);
37+
$data = json_decode($json, true, flags: \JSON_THROW_ON_ERROR);
3838

3939
return new self(
4040
name: $data['name'] ?? throw new \InvalidArgumentException('Property "name" is required.'),

src/Toolkit/src/Kit/KitSynchronizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private function synchronizeRecipes(Kit $kit): void
6565
->name('manifest.json');
6666

6767
if (!$finder->hasResults()) {
68-
throw new \RuntimeException(sprintf('No recipes found at "%s".', $kit->absolutePath));
68+
throw new \RuntimeException(\sprintf('No recipes found at "%s".', $kit->absolutePath));
6969
}
7070

7171
foreach ($finder as $manifestFile) {

src/Toolkit/src/Recipe/Recipe.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Filesystem\Path;
1515
use Symfony\Component\Finder\Finder;
1616
use Symfony\UX\Toolkit\File\File;
17-
use Symfony\UX\Toolkit\File\FileToCopy;
1817

1918
/**
2019
* @author Hugo Alliaume <[email protected]>
@@ -27,9 +26,9 @@ final class Recipe
2726
* @param non-empty-string $absolutePath
2827
*/
2928
public function __construct(
30-
public readonly string $absolutePath,
29+
public readonly string $absolutePath,
3130
public readonly RecipeManifest $manifest,
32-
){
31+
) {
3332
if (!Path::isAbsolute($this->absolutePath)) {
3433
throw new \InvalidArgumentException(\sprintf('Kit path "%s" is not absolute.', $this->absolutePath));
3534
}

src/Toolkit/src/Recipe/RecipeManifest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
final class RecipeManifest
2525
{
2626
/**
27-
* @param non-empty-string $name
28-
* @param non-empty-string $description
27+
* @param non-empty-string $name
28+
* @param non-empty-string $description
2929
* @param array<non-empty-string, non-empty-string> $copyFiles
30-
* @param null|non-empty-string $examplesDir
31-
* @param list<DependencyInterface> $dependencies
30+
* @param non-empty-string|null $examplesDir
31+
* @param list<DependencyInterface> $dependencies
3232
*/
3333
private function __construct(
3434
public readonly RecipeType $type,
@@ -58,11 +58,11 @@ private function __construct(
5858
*/
5959
public static function fromJson(string $json): self
6060
{
61-
$data = json_decode($json, true, flags: JSON_THROW_ON_ERROR);
61+
$data = json_decode($json, true, flags: \JSON_THROW_ON_ERROR);
6262

6363
$dependencies = [];
6464
foreach ($data['dependencies'] as $i => $dependency) {
65-
if (!is_array($dependency)) {
65+
if (!\is_array($dependency)) {
6666
throw new \InvalidArgumentException('Each dependency must be an associative array.');
6767
}
6868
if (!isset($dependency['type'])) {

0 commit comments

Comments
 (0)