Skip to content

Commit 47e9d55

Browse files
committed
chore: cs fixes
1 parent 0e94575 commit 47e9d55

File tree

6 files changed

+43
-66
lines changed

6 files changed

+43
-66
lines changed

src/JsonApi/Serializer/ItemNormalizer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ protected function normalizeRelation(ApiProperty $propertyMetadata, ?object $rel
229229
}
230230

231231
$normalizedRelatedObject = $this->serializer->normalize($relatedObject, $format, $context);
232-
// @phpstan-ignore-next-line throwing an explicit exception helps debugging
233232
if (!\is_string($normalizedRelatedObject) && !\is_array($normalizedRelatedObject) && !$normalizedRelatedObject instanceof \ArrayObject && null !== $normalizedRelatedObject) {
234233
throw new UnexpectedValueException('Expected normalized relation to be an IRI, array, \ArrayObject or null');
235234
}

src/Serializer/AbstractItemNormalizer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,6 @@ protected function normalizeRelation(ApiProperty $propertyMetadata, ?object $rel
651651
}
652652

653653
$normalizedRelatedObject = $this->serializer->normalize($relatedObject, $format, $context);
654-
// @phpstan-ignore-next-line throwing an explicit exception helps debugging
655654
if (!\is_string($normalizedRelatedObject) && !\is_array($normalizedRelatedObject) && !$normalizedRelatedObject instanceof \ArrayObject && null !== $normalizedRelatedObject) {
656655
throw new UnexpectedValueException('Expected normalized relation to be an IRI, array, \ArrayObject or null');
657656
}

tests/Fixtures/DummyAtLeastOneOfValidatedEntity.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@ class DummyAtLeastOneOfValidatedEntity
1919
{
2020
/**
2121
* @var string
22-
*
23-
* @Assert\AtLeastOneOf({
24-
*
25-
* @Assert\Regex("/#/"),
26-
*
27-
* @Assert\Length(min=10)
28-
* })
2922
*/
23+
#[Assert\AtLeastOneOf([
24+
new Assert\Regex('/#/'),
25+
new Assert\Length(min: 10),
26+
])]
3027
public $dummy;
3128
}

tests/Fixtures/DummyCollectionValidatedEntity.php

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,39 +19,31 @@ class DummyCollectionValidatedEntity
1919
{
2020
/**
2121
* @var array
22-
*
23-
* @Assert\Collection(
24-
* allowExtraFields=true,
25-
* fields={
26-
* "name"=@Assert\Required({
27-
*
28-
* @Assert\NotBlank
29-
* }),
30-
* "email"={
31-
*
32-
* @Assert\NotNull,
33-
*
34-
* @Assert\Length(min=2, max=255),
35-
*
36-
* @Assert\Email(mode=Assert\Email::VALIDATION_MODE_HTML5)
37-
* },
38-
* "phone"=@Assert\Optional({
39-
*
40-
* @Assert\Type(type="string"),
41-
*
42-
* @Assert\Regex(pattern="/^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\.\/0-9]*$/")
43-
* }),
44-
* "age"=@Assert\Optional({
45-
*
46-
* @Assert\Type(type="int")
47-
* }),
48-
* "social"=@Assert\Collection(
49-
* fields={
50-
* "githubUsername"=@Assert\NotNull
51-
* }
52-
* )
53-
* }
54-
* )
5522
*/
23+
#[Assert\Collection(
24+
allowExtraFields: true,
25+
fields: [
26+
'name' => new Assert\Required([
27+
new Assert\NotBlank(),
28+
]),
29+
'email' => [
30+
new Assert\NotNull(),
31+
new Assert\Length(min: 2, max: 255),
32+
new Assert\Email(mode: Assert\Email::VALIDATION_MODE_HTML5),
33+
],
34+
'phone' => new Assert\Optional([
35+
new Assert\Type(type: 'string'),
36+
new Assert\Regex(pattern: "/^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\.\/0-9]*$/"),
37+
]),
38+
'age' => new Assert\Optional([
39+
new Assert\Type(type: 'int'),
40+
]),
41+
'social' => new Assert\Collection(
42+
fields: [
43+
'githubUsername' => new Assert\NotNull(),
44+
]
45+
),
46+
]
47+
)]
5648
public $dummyData;
5749
}

tests/Fixtures/DummyValidatedEntity.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,61 +29,51 @@ class DummyValidatedEntity
2929

3030
/**
3131
* @var string A dummy
32-
*
33-
* @Assert\NotBlank
34-
*
35-
* @Assert\Length(max="4", min="10")
36-
*
37-
* @Assert\Regex(pattern="/^dummy$/")
3832
*/
33+
#[Assert\NotBlank]
34+
#[Assert\Length(max: 4, min: 10)]
35+
#[Assert\Regex(pattern: '/^dummy$/')]
3936
public $dummy;
4037

4138
/**
4239
* @var string
43-
*
44-
* @Assert\Email
4540
*/
41+
#[Assert\Email]
4642
public $dummyEmail;
4743

4844
/**
4945
* @var string
50-
*
51-
* @Assert\Uuid
5246
*/
47+
#[Assert\Uuid]
5348
public $dummyUuid;
5449

5550
/**
5651
* @var string
57-
*
58-
* @Assert\Ip
5952
*/
53+
#[Assert\Ip]
6054
public $dummyIpv4;
6155

6256
/**
6357
* @var string
64-
*
65-
* @Assert\Ip(version="6")
6658
*/
59+
#[Assert\Ip(version: '6')]
6760
public $dummyIpv6;
6861

6962
/**
7063
* @var \DateTimeInterface A dummy date
71-
*
72-
* @Assert\Date
7364
*/
65+
#[Assert\Date]
7466
public $dummyDate;
7567

7668
/**
7769
* @var string A dummy group
78-
*
79-
* @Assert\NotNull(groups={"dummy"})
8070
*/
71+
#[Assert\NotNull(groups: ['dummy'])]
8172
public $dummyGroup;
8273

8374
/**
8475
* @var string A dummy url
85-
*
86-
* @Assert\Url
8776
*/
77+
#[Assert\Url]
8878
public $dummyUrl;
8979
}

tests/JsonLd/Serializer/ObjectNormalizerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testNormalize(): void
4949
]);
5050

5151
$normalizer = new ObjectNormalizer(
52-
$serializerProphecy->reveal(), // @phpstan-ignore-line
52+
$serializerProphecy->reveal(),
5353
$iriConverterProphecy->reveal(),
5454
$contextBuilderProphecy->reveal()
5555
);
@@ -78,7 +78,7 @@ public function testNormalizeEmptyArray(): void
7878
$contextBuilderProphecy->getAnonymousResourceContext($dummy, Argument::type('array'))->shouldNotBeCalled();
7979

8080
$normalizer = new ObjectNormalizer(
81-
$serializerProphecy->reveal(), // @phpstan-ignore-line
81+
$serializerProphecy->reveal(),
8282
$iriConverterProphecy->reveal(),
8383
$contextBuilderProphecy->reveal()
8484
);
@@ -102,7 +102,7 @@ public function testNormalizeWithOutput(): void
102102
$contextBuilderProphecy->getAnonymousResourceContext($dummy, ['api_resource' => $dummy, 'iri' => '/dummy/1234'])->shouldBeCalled()->willReturn(['@id' => '/dummy/1234', '@type' => 'Dummy', '@context' => []]);
103103

104104
$normalizer = new ObjectNormalizer(
105-
$serializerProphecy->reveal(), // @phpstan-ignore-line
105+
$serializerProphecy->reveal(),
106106
$iriConverterProphecy->reveal(),
107107
$contextBuilderProphecy->reveal()
108108
);
@@ -132,7 +132,7 @@ public function testNormalizeWithContext(): void
132132
$contextBuilderProphecy->getAnonymousResourceContext($dummy, ['api_resource' => $dummy, 'has_context' => true, 'iri' => '/dummy/1234'])->shouldBeCalled()->willReturn(['@id' => '/dummy/1234', '@type' => 'Dummy']);
133133

134134
$normalizer = new ObjectNormalizer(
135-
$serializerProphecy->reveal(), // @phpstan-ignore-line
135+
$serializerProphecy->reveal(),
136136
$iriConverterProphecy->reveal(),
137137
$contextBuilderProphecy->reveal()
138138
);

0 commit comments

Comments
 (0)