Skip to content

Commit d1ce092

Browse files
committed
fix tests
1 parent 21f8587 commit d1ce092

11 files changed

+60
-43
lines changed

src/Symfony/Extensions/EmptyDataNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function normalize($object, string $format = null, array $context = [])
4141
*/
4242
public function supportsNormalization($data, string $format = null): bool
4343
{
44-
if ( \is_object($data) === true)
44+
if (\is_object($data) === true)
4545
{
4646
$class = \get_class($data);
4747

src/Symfony/Extensions/PropertyNameConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function normalize(string $propertyName): string
3939
*/
4040
public function denormalize(string $propertyName): string
4141
{
42-
if ( isset($this->localStorage[$propertyName]) === false)
42+
if (isset($this->localStorage[$propertyName]) === false)
4343
{
4444
$joinedString = \preg_replace_callback(
4545
'/_(.?)/',

src/Symfony/Extensions/PropertyNormalizerWrapper.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ protected function instantiateObject(
3838
\ReflectionClass $reflectionClass,
3939
$allowedAttributes,
4040
string $format = null
41-
): object
42-
{
41+
): object {
4342
return $reflectionClass->newInstanceWithoutConstructor();
4443
}
4544

@@ -50,7 +49,7 @@ protected function extractAttributes(object $object, string $format = null, arra
5049
{
5150
$class = \get_class($object);
5251

53-
if(\array_key_exists($class, $this->localStorage) === false)
52+
if (\array_key_exists($class, $this->localStorage) === false)
5453
{
5554
$this->localStorage[$class] = parent::extractAttributes($object, $format, $context);
5655
}
@@ -65,7 +64,7 @@ protected function extractAttributes(object $object, string $format = null, arra
6564
*/
6665
protected function getAttributeValue(object $object, string $attribute, string $format = null, array $context = [])
6766
{
68-
if(isset($object->{$attribute}) === true)
67+
if (isset($object->{$attribute}) === true)
6968
{
7069
return $object->{$attribute};
7170
}
@@ -74,9 +73,9 @@ protected function getAttributeValue(object $object, string $attribute, string $
7473
{
7574
return parent::getAttributeValue($object, $attribute, $format, $context);
7675
}
77-
catch(\Error $error)
76+
catch (\Error $error)
7877
{
79-
if(\strpos($error->getMessage(), 'must not be accessed before initialization') !== false)
78+
if (\strpos($error->getMessage(), 'must not be accessed before initialization') !== false)
8079
{
8180
return null;
8281
}
@@ -92,7 +91,7 @@ protected function getAttributeValue(object $object, string $attribute, string $
9291
*/
9392
protected function setAttributeValue(object $object, string $attribute, $value, string $format = null, array $context = []): void
9493
{
95-
if(isset($object->{$attribute}) === true)
94+
if (isset($object->{$attribute}) === true)
9695
{
9796
$object->{$attribute} = $value;
9897

src/Symfony/Extractor/FailOverExtractor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ public function getTypes(string $class, string $property, array $context = []):
4242
{
4343
$cacheKey = \sha1($class . $property);
4444

45-
if(\array_key_exists($cacheKey, $this->localStorage) === false)
45+
if (\array_key_exists($cacheKey, $this->localStorage) === false)
4646
{
4747
$this->localStorage[$cacheKey] = null;
4848

49-
foreach($this->extractors as $extractor)
49+
foreach ($this->extractors as $extractor)
5050
{
5151
$types = $extractor->getTypes($class, $property, $context);
5252

53-
if(null !== $types)
53+
if (null !== $types)
5454
{
5555
$this->localStorage[$cacheKey] = $types;
5656

src/Symfony/SymfonyMessageSerializer.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function encode(object $message): string
7676

7777
return $this->serializer->serialize($data);
7878
}
79-
catch(\Throwable $throwable)
79+
catch (\Throwable $throwable)
8080
{
8181
throw new EncodeMessageFailed($throwable->getMessage(), (int) $throwable->getCode(), $throwable);
8282
}
@@ -99,7 +99,7 @@ public function decode(string $serializedMessage): object
9999

100100
return $object;
101101
}
102-
catch(\Throwable $throwable)
102+
catch (\Throwable $throwable)
103103
{
104104
throw new DecodeMessageFailed($throwable->getMessage(), (int) $throwable->getCode(), $throwable);
105105
}
@@ -120,7 +120,7 @@ public function denormalize(array $payload, string $class): object
120120

121121
return $object;
122122
}
123-
catch(\Throwable $throwable)
123+
catch (\Throwable $throwable)
124124
{
125125
throw new DenormalizeFailed($throwable->getMessage(), (int) $throwable->getCode(), $throwable);
126126
}
@@ -135,7 +135,7 @@ public function normalize(object $message): array
135135
{
136136
$data = $this->normalizer->normalize($message);
137137

138-
if(\is_array($data) === true)
138+
if (\is_array($data) === true)
139139
{
140140
/** @psalm-var array<string, mixed> $data */
141141

@@ -152,7 +152,7 @@ public function normalize(object $message): array
152152
);
153153
// @codeCoverageIgnoreEnd
154154
}
155-
catch(\Throwable $throwable)
155+
catch (\Throwable $throwable)
156156
{
157157
throw new NormalizationFailed($throwable->getMessage(), (int) $throwable->getCode(), $throwable);
158158
}
@@ -166,11 +166,10 @@ public function normalize(object $message): array
166166
private static function validateUnserializedData(array $data): void
167167
{
168168
/** Let's check if there are mandatory fields */
169-
if(
169+
if (
170170
isset($data['namespace']) === false ||
171171
isset($data['message']) === false
172-
)
173-
{
172+
) {
174173
throw new \UnexpectedValueException(
175174
'The serialized data must contains a "namespace" field (indicates the message class) and "message" (indicates the message parameters)'
176175
);
@@ -181,7 +180,7 @@ private static function validateUnserializedData(array $data): void
181180
*
182181
* @psalm-suppress DocblockTypeContradiction
183182
*/
184-
if($data['namespace'] === '' || \class_exists((string) $data['namespace']) === false)
183+
if ($data['namespace'] === '' || \class_exists((string) $data['namespace']) === false)
185184
{
186185
throw new \UnexpectedValueException(
187186
\sprintf('Class "%s" not found', $data['namespace'])

tests/Stubs/AuthorCollection.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,5 @@ final class AuthorCollection
1919
/**
2020
* @var Author[]
2121
*/
22-
public array
23-
24-
$collection;
22+
public $collection;
2523
}

tests/Stubs/ClassWithPrivateConstructor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class ClassWithPrivateConstructor
2020
/**
2121
* @var string
2222
*/
23-
public string $value;
23+
public $value;
2424

2525
/**
2626
* @param mixed

tests/Stubs/TestMessage.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,24 @@
1717
*/
1818
final class TestMessage
1919
{
20-
private string $componentName;
21-
22-
private ?string $stableVersion;
23-
24-
private string $devVersion;
25-
26-
private Author $author;
20+
/**
21+
* @var string
22+
*/
23+
private $componentName;
24+
/**
25+
* @var string|null
26+
*/
27+
private $stableVersion;
28+
29+
/**
30+
* @var string
31+
*/
32+
private $devVersion;
33+
34+
/**
35+
* @var Author
36+
*/
37+
private $author;
2738

2839
public static function create(string $componentName, ?string $stableVersion, string $devVersion, Author $author): self
2940
{
@@ -37,8 +48,8 @@ private function __construct(string $componentName, ?string $stableVersion, stri
3748
/** @noinspection UnusedConstructorDependenciesInspection */
3849
$this->stableVersion = $stableVersion;
3950
/** @noinspection UnusedConstructorDependenciesInspection */
40-
$this->devVersion = $devVersion;
51+
$this->devVersion = $devVersion;
4152
/** @noinspection UnusedConstructorDependenciesInspection */
42-
$this->author = $author;
53+
$this->author = $author;
4354
}
4455
}

tests/Stubs/WithDateTimeField.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
*/
1818
final class WithDateTimeField
1919
{
20-
public \DateTimeImmutable $dateTimeValue;
20+
/**
21+
* @var \DateTimeImmutable
22+
*/
23+
public $dateTimeValue;
2124

2225
public function __construct(\DateTimeImmutable $dateTimeValue)
2326
{

tests/Stubs/WithNullableObjectArgument.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@
1717
*/
1818
final class WithNullableObjectArgument
1919
{
20-
public string $value;
21-
22-
private ?ClassWithPrivateConstructor $object;
20+
/**
21+
* @var string
22+
*/
23+
public $value;
24+
25+
/**
26+
* @var ClassWithPrivateConstructor|null
27+
*/
28+
private $object;
2329

2430
public static function withObject(string $value, ClassWithPrivateConstructor $object): self
2531
{

0 commit comments

Comments
 (0)