Skip to content

Commit dd19036

Browse files
authored
Merge pull request #184 from patchlevel/1.23.x-merge-up-into-2.0.x_wUkDI09K
Merge release 1.23.0 into 2.0.x
2 parents 469d387 + 448dbe5 commit dd19036

22 files changed

Lines changed: 132 additions & 308 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ phpunit: vendor
2727

2828
.PHONY: infection
2929
infection: vendor ## run infection
30-
XDEBUG_MODE=coverage vendor/bin/infection --threads=3
30+
XDEBUG_MODE=coverage php -d memory_limit=312M vendor/bin/infection --threads=3
3131

3232
.PHONY: static
3333
static: phpstan cs ## run static analysers

infection.json.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"mutators": {
1717
"@default": true
1818
},
19-
"minMsi": 89,
20-
"minCoveredMsi": 88,
19+
"minMsi": 91,
20+
"minCoveredMsi": 91,
2121
"testFrameworkOptions": "--testsuite=unit"
2222
}

phpstan-baseline.neon

Lines changed: 4 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -48,42 +48,6 @@ parameters:
4848
count: 1
4949
path: src/Extension/Cryptography/Cipher/OpensslCipherKeyFactory.php
5050

51-
-
52-
message: '#^Parameter \$legacyCryptographer of method Patchlevel\\Hydrator\\Extension\\Cryptography\\CryptographyExtension\:\:__construct\(\) has invalid type Patchlevel\\Hydrator\\Cryptography\\PayloadCryptographer\.$#'
53-
identifier: class.notFound
54-
count: 1
55-
path: src/Extension/Cryptography/CryptographyExtension.php
56-
57-
-
58-
message: '#^Property Patchlevel\\Hydrator\\Extension\\Cryptography\\CryptographyExtension\:\:\$legacyCryptographer has unknown class Patchlevel\\Hydrator\\Cryptography\\PayloadCryptographer as its type\.$#'
59-
identifier: class.notFound
60-
count: 1
61-
path: src/Extension/Cryptography/CryptographyExtension.php
62-
63-
-
64-
message: '#^Call to method decrypt\(\) on an unknown class Patchlevel\\Hydrator\\Cryptography\\PayloadCryptographer\.$#'
65-
identifier: class.notFound
66-
count: 1
67-
path: src/Extension/Cryptography/LegacyCryptographyDecryptMiddleware.php
68-
69-
-
70-
message: '#^Parameter \#2 \$data of method Patchlevel\\Hydrator\\Middleware\\Middleware\:\:hydrate\(\) expects array\<string, mixed\>, mixed given\.$#'
71-
identifier: argument.type
72-
count: 1
73-
path: src/Extension/Cryptography/LegacyCryptographyDecryptMiddleware.php
74-
75-
-
76-
message: '#^Parameter \$payloadCryptographer of method Patchlevel\\Hydrator\\Extension\\Cryptography\\LegacyCryptographyDecryptMiddleware\:\:__construct\(\) has invalid type Patchlevel\\Hydrator\\Cryptography\\PayloadCryptographer\.$#'
77-
identifier: class.notFound
78-
count: 1
79-
path: src/Extension/Cryptography/LegacyCryptographyDecryptMiddleware.php
80-
81-
-
82-
message: '#^Property Patchlevel\\Hydrator\\Extension\\Cryptography\\LegacyCryptographyDecryptMiddleware\:\:\$payloadCryptographer has unknown class Patchlevel\\Hydrator\\Cryptography\\PayloadCryptographer as its type\.$#'
83-
identifier: class.notFound
84-
count: 1
85-
path: src/Extension/Cryptography/LegacyCryptographyDecryptMiddleware.php
86-
8751
-
8852
message: '#^Method Patchlevel\\Hydrator\\Guesser\\BuiltInGuesser\:\:guess\(\) has parameter \$type with generic class Symfony\\Component\\TypeInfo\\Type\\ObjectType but does not specify its types\: T$#'
8953
identifier: missingType.generics
@@ -132,12 +96,6 @@ parameters:
13296
count: 1
13397
path: src/Metadata/ClassMetadata.php
13498

135-
-
136-
message: '#^Access to constant OBJECT_TO_POPULATE on an unknown class Patchlevel\\Hydrator\\HydratorWithContext\.$#'
137-
identifier: class.notFound
138-
count: 2
139-
path: src/Middleware/TransformMiddleware.php
140-
14199
-
142100
message: '#^Method Patchlevel\\Hydrator\\Middleware\\TransformMiddleware\:\:hydrate\(\) should return T of object but returns mixed\.$#'
143101
identifier: return.type
@@ -151,10 +109,10 @@ parameters:
151109
path: src/Middleware/TransformMiddleware.php
152110

153111
-
154-
message: '#^Possibly invalid array key type mixed\.$#'
155-
identifier: offsetAccess.invalidOffset
156-
count: 2
157-
path: src/Middleware/TransformMiddleware.php
112+
message: '#^Attribute class Patchlevel\\Hydrator\\Normalizer\\Deprecated does not exist\.$#'
113+
identifier: attribute.notFound
114+
count: 1
115+
path: src/Normalizer/EnumNormalizer.php
158116

159117
-
160118
message: '#^Property Patchlevel\\Hydrator\\Normalizer\\EnumNormalizer\:\:\$enum \(class\-string\<BackedEnum\>\|null\) does not accept string\.$#'
@@ -180,18 +138,6 @@ parameters:
180138
count: 1
181139
path: tests/Unit/Extension/Cryptography/Fixture/ChildWithSensitiveDataWithIdentifierDto.php
182140

183-
-
184-
message: '#^Call to method expects\(\) on an unknown class Patchlevel\\Hydrator\\Cryptography\\PayloadCryptographer\.$#'
185-
identifier: class.notFound
186-
count: 2
187-
path: tests/Unit/Extension/Cryptography/LegacyCryptographyDecryptMiddlewareTest.php
188-
189-
-
190-
message: '#^Class Patchlevel\\Hydrator\\Cryptography\\PayloadCryptographer not found\.$#'
191-
identifier: class.notFound
192-
count: 2
193-
path: tests/Unit/Extension/Cryptography/LegacyCryptographyDecryptMiddlewareTest.php
194-
195141
-
196142
message: '#^Property Patchlevel\\Hydrator\\Tests\\Unit\\Fixture\\IdNormalizer\:\:\$idClass \(class\-string\<Patchlevel\\Hydrator\\Tests\\Unit\\Fixture\\Id\>\|null\) does not accept string\.$#'
197143
identifier: assign.propertyType
@@ -228,26 +174,8 @@ parameters:
228174
count: 2
229175
path: tests/Unit/Normalizer/ArrayShapeNormalizerTest.php
230176

231-
-
232-
message: '#^Access to undefined constant Patchlevel\\Hydrator\\StackHydrator\:\:OBJECT_TO_POPULATE\.$#'
233-
identifier: classConstant.notFound
234-
count: 1
235-
path: tests/Unit/StackHydratorTest.php
236-
237177
-
238178
message: '#^Parameter \#1 \$class of method Patchlevel\\Hydrator\\StackHydrator\:\:hydrate\(\) expects class\-string\<Unknown\>, string given\.$#'
239179
identifier: argument.type
240180
count: 1
241181
path: tests/Unit/StackHydratorTest.php
242-
243-
-
244-
message: '#^Parameter \#3 \$context of method Patchlevel\\Hydrator\\StackHydrator\:\:hydrate\(\) expects array\<string, mixed\>, array\<Patchlevel\\Hydrator\\Tests\\Unit\\Fixture\\ProfileCreated\> given\.$#'
245-
identifier: argument.type
246-
count: 1
247-
path: tests/Unit/StackHydratorTest.php
248-
249-
-
250-
message: '#^Possibly invalid array key type mixed\.$#'
251-
identifier: array.invalidKey
252-
count: 1
253-
path: tests/Unit/StackHydratorTest.php

src/Extension/Cryptography/CryptographyExtension.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,19 @@
44

55
namespace Patchlevel\Hydrator\Extension\Cryptography;
66

7-
use Patchlevel\Hydrator\Cryptography\PayloadCryptographer;
87
use Patchlevel\Hydrator\Extension;
98
use Patchlevel\Hydrator\StackHydratorBuilder;
109

1110
final class CryptographyExtension implements Extension
1211
{
1312
public function __construct(
1413
private readonly Cryptographer $cryptography,
15-
private readonly PayloadCryptographer|null $legacyCryptographer = null,
1614
) {
1715
}
1816

1917
public function configure(StackHydratorBuilder $builder): void
2018
{
2119
$builder->addMetadataEnricher(new CryptographyMetadataEnricher(), 64);
2220
$builder->addMiddleware(new CryptographyMiddleware($this->cryptography), 64);
23-
24-
if ($this->legacyCryptographer === null) {
25-
return;
26-
}
27-
28-
$builder->addMiddleware(new LegacyCryptographyDecryptMiddleware($this->legacyCryptographer), 65);
2921
}
3022
}

src/Extension/Cryptography/CryptographyMiddleware.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ public function hydrate(ClassMetadata $metadata, array $data, array $context, St
3838
{
3939
$context[SubjectIds::class] = $subjectIds = $this->resolveSubjectIds($metadata, $data, $context);
4040

41-
if ($context[LegacyCryptographyDecryptMiddleware::class] ?? false) {
42-
unset($context[LegacyCryptographyDecryptMiddleware::class]);
43-
44-
return $stack->next()->hydrate($metadata, $data, $context, $stack);
45-
}
46-
4741
foreach ($metadata->properties as $propertyMetadata) {
4842
$info = $propertyMetadata->extras[SensitiveDataInfo::class] ?? null;
4943

src/Extension/Cryptography/LegacyCryptographyDecryptMiddleware.php

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

src/Hydrator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
interface Hydrator
88
{
9+
public const OBJECT_TO_POPULATE = 'object_to_populate';
10+
911
/**
1012
* @param class-string<T> $class
1113
* @param array<string, mixed> $context

src/Middleware/TransformMiddleware.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use Patchlevel\Hydrator\CircularReference;
88
use Patchlevel\Hydrator\DenormalizationFailure;
9-
use Patchlevel\Hydrator\HydratorWithContext;
9+
use Patchlevel\Hydrator\Hydrator;
1010
use Patchlevel\Hydrator\Metadata\ClassMetadata;
1111
use Patchlevel\Hydrator\NormalizationFailure;
1212
use Patchlevel\Hydrator\TypeMismatch;
@@ -33,8 +33,8 @@ final class TransformMiddleware implements Middleware
3333
*/
3434
public function hydrate(ClassMetadata $metadata, array $data, array $context, Stack $stack): object
3535
{
36-
$object = $context[HydratorWithContext::OBJECT_TO_POPULATE] ?? $metadata->newInstance();
37-
unset($context[HydratorWithContext::OBJECT_TO_POPULATE]);
36+
$object = $context[Hydrator::OBJECT_TO_POPULATE] ?? $metadata->newInstance();
37+
unset($context[Hydrator::OBJECT_TO_POPULATE]);
3838

3939
$constructorParameters = null;
4040

src/Normalizer/ArrayNormalizer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,9 @@ public function handleType(Type|null $type): void
8989

9090
$this->normalizer->handleType($type->getCollectionValueType());
9191
}
92+
93+
public function innerNormalizer(): Normalizer
94+
{
95+
return $this->normalizer;
96+
}
9297
}

src/Normalizer/ArrayShapeNormalizer.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,10 @@ public function handleType(Type|null $type): void
112112
$normalizer->handleType($shape[$field]['type']);
113113
}
114114
}
115+
116+
/** @return array<array-key, Normalizer> */
117+
public function innerNormalizers(): array
118+
{
119+
return $this->normalizerMap;
120+
}
115121
}

0 commit comments

Comments
 (0)