Skip to content

Commit e23a80e

Browse files
committed
#11 cs-fixer
1 parent 1e78f64 commit e23a80e

File tree

7 files changed

+30
-34
lines changed

7 files changed

+30
-34
lines changed

src/Component/ComponentItemFactory.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,15 @@ private function parseVariations(?array $variations, ?array $parameters): array
103103

104104
if (!$variations) {
105105
return [
106-
'default' => $this->faker->getFakeData($parameters)
106+
'default' => $this->faker->getFakeData($parameters),
107107
];
108108
}
109109

110110
$result = [];
111111

112112
foreach ($variations as $variationName => $variationParams) {
113-
if (!is_array($variationParams)) {
114-
throw new InvalidComponentConfigurationException(
115-
ConstraintViolationList::createFromMessage(
116-
sprintf('A component variation must contain an array of parameters. Variation Name: %s', $variationName)
117-
)
118-
);
113+
if (!\is_array($variationParams)) {
114+
throw new InvalidComponentConfigurationException(ConstraintViolationList::createFromMessage(sprintf('A component variation must contain an array of parameters. Variation Name: %s', $variationName)));
119115
}
120116
$result[$variationName] = $this->faker->getFakeData($parameters, $variationParams);
121117
}

src/Component/Data/Faker.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Symfony\Component\PropertyInfo\Type;
1111

1212
/**
13-
* Creates fake data to be used in variation display for components
13+
* Creates fake data to be used in variation display for components.
1414
*
1515
* Provide seed in constructor to get reproducible random values
1616
*/
@@ -41,7 +41,7 @@ private function collectClasses(array $params, array $variation = []): ?array
4141
{
4242
$classes = [];
4343
foreach ($params as $name => $type) {
44-
if (is_array($type)) {
44+
if (\is_array($type)) {
4545
$classes[$name] = $this->collectClasses($type, $variation[$name] ?? []);
4646
} elseif (class_exists($type)) {
4747
$propertyInfo = $this->getPropertyInfo($type);
@@ -62,7 +62,7 @@ private function collectClasses(array $params, array $variation = []): ?array
6262
private function getFixtureParams(string $className, array $props = [], array $params = []): array
6363
{
6464
foreach ($props as $prop => $type) {
65-
if (!array_key_exists($prop, $params) && $this->extractor->isWritable($className, $prop)) {
65+
if (!\array_key_exists($prop, $params) && $this->extractor->isWritable($className, $prop)) {
6666
$params[$prop] = $this->createParamValue($type->getBuiltinType());
6767
}
6868
}
@@ -128,9 +128,9 @@ private function getFixture(string $fixtureSetName, FixtureData $data): object
128128
$prop => array_merge(
129129
$data->params[$prop]
130130
?? $this->getFixtureParams($type->getClassName(), $this->getPropertyInfo($type->getClassName())),
131-
['__construct' => false, ]
132-
)
133-
] ;
131+
['__construct' => false]
132+
),
133+
];
134134
$fixtureParams[$prop] = sprintf('@%s', $prop);
135135
}
136136
}
@@ -141,7 +141,7 @@ private function getFixture(string $fixtureSetName, FixtureData $data): object
141141
// disable constructor until we have time to fake constructor arguments :-)
142142
'__construct' => false,
143143
]),
144-
]
144+
],
145145
]);
146146

147147
return $this->loader->loadData($fixtureData)->getObjects()[$fixtureSetName];
@@ -153,7 +153,7 @@ public function createVariationParameters(array $parameters, array $variation):
153153
foreach ($parameters as $name => $type) {
154154
if (\is_array($type)) {
155155
$paramValue = $this->createVariationParameters($type, $variation[$name] ?? []);
156-
} elseif (array_key_exists($name, $variation)) {
156+
} elseif (\array_key_exists($name, $variation)) {
157157
$paramValue = $variation[$name];
158158
} else {
159159
$paramValue = $this->createParamValue($type);
@@ -189,7 +189,7 @@ private function arrayDiffKeyRecursive(array $arr1, array $arr2): array
189189
$intersect = array_intersect_key($arr1, $arr2);
190190

191191
foreach ($intersect as $k => $v) {
192-
if (is_array($arr1[$k]) && is_array($arr2[$k])) {
192+
if (\is_array($arr1[$k]) && \is_array($arr2[$k])) {
193193
$d = $this->arrayDiffKeyRecursive($arr1[$k], $arr2[$k]);
194194

195195
if ($d) {

src/Component/Data/FixtureData.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class FixtureData
1212
public function __construct(
1313
public readonly string $className,
1414
/** @param array<string, Type> $properties */
15-
public readonly array $properties,
16-
public readonly array $params = []
15+
public readonly array $properties,
16+
public readonly array $params = []
1717
) {
1818
}
1919
}

tests/Functional/Service/ComponentItemFactoryTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Qossmic\TwigDocBundle\Exception\InvalidComponentConfigurationException;
1414
use Qossmic\TwigDocBundle\Service\CategoryService;
1515
use Qossmic\TwigDocBundle\Tests\TestApp\Entity\Car;
16-
use Qossmic\TwigDocBundle\Tests\TestApp\Entity\Manufacturer;
1716
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1817
use Symfony\Component\Validator\Validator\ValidatorInterface;
1918

@@ -142,18 +141,18 @@ public function testCreateForObjectParameter(): void
142141
'path' => 'path',
143142
'renderPath' => 'renderPath',
144143
'parameters' => [
145-
'car' => Car::class
144+
'car' => Car::class,
146145
],
147146
'variations' => [
148147
'fuchsia' => [
149148
'car' => [
150149
'color' => 'fuchsia',
151150
'manufacturer' => [
152151
'name' => 'Mitsubishi',
153-
]
154-
]
155-
]
156-
]
152+
],
153+
],
154+
],
155+
],
157156
];
158157

159158
/** @var ComponentItemFactory $factory */

tests/TestApp/Entity/Car.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,19 @@ class Car
1212

1313
public function __construct(private readonly string $blub)
1414
{
15-
1615
}
16+
1717
public function getBlub(): string
1818
{
1919
return $this->blub;
2020
}
21+
2122
public function getManufacturer(): ?Manufacturer
2223
{
2324
return $this->manufacturer;
2425
}
2526

26-
public function setManufacturer(Manufacturer $manufacturer): Car
27+
public function setManufacturer(Manufacturer $manufacturer): self
2728
{
2829
$this->manufacturer = $manufacturer;
2930

@@ -35,7 +36,7 @@ public function getColor(): string
3536
return $this->color;
3637
}
3738

38-
public function setColor(string $color): Car
39+
public function setColor(string $color): self
3940
{
4041
$this->color = $color;
4142

tests/TestApp/Entity/Manufacturer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function getName(): string
1111
return $this->name;
1212
}
1313

14-
public function setName(string $name): Manufacturer
14+
public function setName(string $name): self
1515
{
1616
$this->name = $name;
1717

tests/Unit/Component/Data/FakerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public function testGetFakeDataWithoutVariationData(): void
3333
'someDouble' => 'Double',
3434
'someResource' => 'Resource',
3535
'someNull' => 'null',
36-
]
37-
]
36+
],
37+
],
3838
];
3939

4040
$faker = new Faker();
@@ -65,21 +65,21 @@ public function testGetFakeDataForVariation(): void
6565
'text' => 'String',
6666
'complex' => [
6767
'manufacturer' => Manufacturer::class,
68-
]
68+
],
6969
];
7070
$variation = [
7171
'car' => [
7272
'color' => 'pink',
7373
'manufacturer' => [
7474
'name' => 'Toyota',
75-
]
75+
],
7676
],
7777
'text' => 'shouldStayAsIs',
7878
'complex' => [
7979
'manufacturer' => [
8080
'name' => 'Mitsubishi',
81-
]
82-
]
81+
],
82+
],
8383
];
8484

8585
$faker = new Faker();

0 commit comments

Comments
 (0)