Skip to content

Commit 2026dfb

Browse files
committed
rename metadata hydrator into stack hydrator
1 parent b2805db commit 2026dfb

14 files changed

+63
-70
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ composer require patchlevel/hydrator
2727
To use the hydrator you just have to create an instance of it.
2828

2929
```php
30-
use Patchlevel\Hydrator\MetadataHydrator;
30+
use Patchlevel\Hydrator\StackHydrator;
3131

32-
$hydrator = MetadataHydrator::create();
32+
$hydrator = StackHydrator::create();
3333
```
3434

3535
After that you can hydrate any classes or objects. Also `final`, `readonly` classes with `property promotion`.
@@ -483,9 +483,9 @@ class NameGuesser implements Guesser
483483
To use this Guesser, you must specify it when creating the Hydrator:
484484

485485
```php
486-
use Patchlevel\Hydrator\MetadataHydrator;
486+
use Patchlevel\Hydrator\StackHydrator;
487487

488-
$hydrator = MetadataHydrator::create([new NameGuesser()]);
488+
$hydrator = StackHydrator::create([new NameGuesser()]);
489489
```
490490

491491
> [!NOTE]
@@ -595,7 +595,7 @@ For this functionality we use the [symfony/event-dispatcher](https://symfony.com
595595
use Patchlevel\Hydrator\Cryptography\SensitiveDataPayloadCryptographer;
596596
use Patchlevel\Hydrator\Cryptography\Store\CipherKeyStore;
597597
use Patchlevel\Hydrator\Metadata\Event\EventMetadataFactory;
598-
use Patchlevel\Hydrator\MetadataHydrator;
598+
use Patchlevel\Hydrator\StackHydrator;
599599
use Symfony\Component\EventDispatcher\EventDispatcher;
600600
use Patchlevel\Hydrator\Event\PostExtract;
601601
use Patchlevel\Hydrator\Event\PreHydrate;
@@ -616,7 +616,7 @@ $eventDispatcher->addListener(
616616
}
617617
);
618618

619-
$hydrator = new MetadataHydrator(eventDispatcher: $eventDispatcher);
619+
$hydrator = new StackHydrator(eventDispatcher: $eventDispatcher);
620620
```
621621

622622
### Cryptography
@@ -742,11 +742,11 @@ Here we show you how to configure the cryptography.
742742
use Patchlevel\Hydrator\Cryptography\SensitiveDataPayloadCryptographer;
743743
use Patchlevel\Hydrator\Cryptography\Store\CipherKeyStore;
744744
use Patchlevel\Hydrator\Metadata\Event\EventMetadataFactory;
745-
use Patchlevel\Hydrator\MetadataHydrator;
745+
use Patchlevel\Hydrator\StackHydrator;
746746

747747
$cipherKeyStore = new InMemoryCipherKeyStore();
748748
$cryptographer = SensitiveDataPayloadCryptographer::createWithDefaultSettings($cipherKeyStore);
749-
$hydrator = new MetadataHydrator(cryptographer: $cryptographer);
749+
$hydrator = new StackHydrator(cryptographer: $cryptographer);
750750
```
751751

752752
> [!WARNING]

phpstan-baseline.neon

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ parameters:
7272
count: 1
7373
path: src/Metadata/ClassMetadata.php
7474

75-
-
76-
message: '#^Parameter \#2 \$data of method Patchlevel\\Hydrator\\Middleware\\Middleware\:\:hydrate\(\) expects array\<string, mixed\>, array\<mixed, mixed\> given\.$#'
77-
identifier: argument.type
78-
count: 3
79-
path: src/MetadataHydrator.php
80-
8175
-
8276
message: '#^Property Patchlevel\\Hydrator\\Normalizer\\EnumNormalizer\:\:\$enum \(class\-string\<BackedEnum\>\|null\) does not accept string\.$#'
8377
identifier: assign.propertyType
@@ -90,6 +84,12 @@ parameters:
9084
count: 1
9185
path: src/Normalizer/ObjectNormalizer.php
9286

87+
-
88+
message: '#^Parameter \#2 \$data of method Patchlevel\\Hydrator\\Middleware\\Middleware\:\:hydrate\(\) expects array\<string, mixed\>, array\<mixed, mixed\> given\.$#'
89+
identifier: argument.type
90+
count: 3
91+
path: src/StackHydrator.php
92+
9393
-
9494
message: '#^Property Patchlevel\\Hydrator\\Tests\\Unit\\Extension\\Cryptography\\Fixture\\ChildWithSensitiveDataWithIdentifierDto\:\:\$email is never read, only written\.$#'
9595
identifier: property.onlyWritten
@@ -108,12 +108,6 @@ parameters:
108108
count: 1
109109
path: tests/Unit/Metadata/AttributeMetadataFactoryTest.php
110110

111-
-
112-
message: '#^Parameter \#1 \$class of method Patchlevel\\Hydrator\\MetadataHydrator\:\:hydrate\(\) expects class\-string\<Unknown\>, string given\.$#'
113-
identifier: argument.type
114-
count: 1
115-
path: tests/Unit/MetadataHydratorTest.php
116-
117111
-
118112
message: '#^Cannot cast mixed to int\.$#'
119113
identifier: cast.int
@@ -137,3 +131,9 @@ parameters:
137131
identifier: cast.string
138132
count: 2
139133
path: tests/Unit/Normalizer/ArrayShapeNormalizerTest.php
134+
135+
-
136+
message: '#^Parameter \#1 \$class of method Patchlevel\\Hydrator\\StackHydrator\:\:hydrate\(\) expects class\-string\<Unknown\>, string given\.$#'
137+
identifier: argument.type
138+
count: 1
139+
path: tests/Unit/StackHydratorTest.php

src/CoreExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
final class CoreExtension implements Extension
1111
{
12-
public function configure(HydratorBuilder $builder): void
12+
public function configure(StackHydratorBuilder $builder): void
1313
{
1414
$builder->addMiddleware(new TransformMiddleware(), -64);
1515
$builder->addGuesser(new BuiltInGuesser(), -64);

src/Extension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
interface Extension
88
{
9-
public function configure(HydratorBuilder $builder): void;
9+
public function configure(StackHydratorBuilder $builder): void;
1010
}

src/Extension/Cryptography/CryptographyExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Patchlevel\Hydrator\Extension\Cryptography;
66

77
use Patchlevel\Hydrator\Extension;
8-
use Patchlevel\Hydrator\HydratorBuilder;
8+
use Patchlevel\Hydrator\StackHydratorBuilder;
99

1010
final class CryptographyExtension implements Extension
1111
{
@@ -14,7 +14,7 @@ public function __construct(
1414
) {
1515
}
1616

17-
public function configure(HydratorBuilder $builder): void
17+
public function configure(StackHydratorBuilder $builder): void
1818
{
1919
$builder->addMetadataEnricher(new CryptographyMetadataEnricher(), 64);
2020
$builder->addMiddleware(new CryptographyMiddleware($this->cryptography), 64);

src/Extension/Lifecycle/LifecycleExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
namespace Patchlevel\Hydrator\Extension\Lifecycle;
66

77
use Patchlevel\Hydrator\Extension;
8-
use Patchlevel\Hydrator\HydratorBuilder;
8+
use Patchlevel\Hydrator\StackHydratorBuilder;
99

1010
final readonly class LifecycleExtension implements Extension
1111
{
12-
public function configure(HydratorBuilder $builder): void
12+
public function configure(StackHydratorBuilder $builder): void
1313
{
1414
$builder->addMiddleware(new LifecycleMiddleware());
1515
$builder->addMetadataEnricher(new LifecycleMetadataEnricher());
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
use const PHP_VERSION_ID;
2121

22-
final class MetadataHydrator implements Hydrator
22+
final class StackHydrator implements Hydrator
2323
{
2424
/** @var array<class-string, ClassMetadata> */
2525
private array $classMetadata = [];
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use function array_merge;
1919
use function krsort;
2020

21-
final class HydratorBuilder
21+
final class StackHydratorBuilder
2222
{
2323
private bool $defaultLazy = false;
2424

@@ -78,7 +78,7 @@ public function setCache(CacheItemPoolInterface|CacheInterface|null $cache): sta
7878
return $this;
7979
}
8080

81-
public function build(): Hydrator
81+
public function build(): StackHydrator
8282
{
8383
krsort($this->guessers);
8484
krsort($this->metadataEnrichers);
@@ -99,7 +99,7 @@ public function build(): Hydrator
9999
$metadataFactory = new Psr16MetadataFactory($metadataFactory, $this->cache);
100100
}
101101

102-
return new MetadataHydrator(
102+
return new StackHydrator(
103103
$metadataFactory,
104104
array_merge(...$this->middlewares),
105105
$this->defaultLazy,

tests/Benchmark/HydratorBench.php

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

77
use Patchlevel\Hydrator\CoreExtension;
88
use Patchlevel\Hydrator\Hydrator;
9-
use Patchlevel\Hydrator\HydratorBuilder;
9+
use Patchlevel\Hydrator\StackHydratorBuilder;
1010
use Patchlevel\Hydrator\Tests\Benchmark\Fixture\ProfileCreated;
1111
use Patchlevel\Hydrator\Tests\Benchmark\Fixture\ProfileId;
1212
use Patchlevel\Hydrator\Tests\Benchmark\Fixture\Skill;
@@ -19,7 +19,7 @@ final class HydratorBench
1919

2020
public function __construct()
2121
{
22-
$this->hydrator = (new HydratorBuilder())
22+
$this->hydrator = (new StackHydratorBuilder())
2323
->useExtension(new CoreExtension())
2424
->build();
2525
}

tests/Benchmark/HydratorWithCryptographyBench.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Patchlevel\Hydrator\Extension\Cryptography\CryptographyExtension;
1010
use Patchlevel\Hydrator\Extension\Cryptography\Store\InMemoryCipherKeyStore;
1111
use Patchlevel\Hydrator\Hydrator;
12-
use Patchlevel\Hydrator\HydratorBuilder;
12+
use Patchlevel\Hydrator\StackHydratorBuilder;
1313
use Patchlevel\Hydrator\Tests\Benchmark\Fixture\ProfileCreated;
1414
use Patchlevel\Hydrator\Tests\Benchmark\Fixture\ProfileId;
1515
use Patchlevel\Hydrator\Tests\Benchmark\Fixture\Skill;
@@ -26,7 +26,7 @@ public function __construct()
2626
{
2727
$this->store = new InMemoryCipherKeyStore();
2828

29-
$this->hydrator = (new HydratorBuilder())
29+
$this->hydrator = (new StackHydratorBuilder())
3030
->useExtension(new CoreExtension())
3131
->useExtension(new CryptographyExtension(BaseCryptographer::createWithOpenssl($this->store)))
3232
->build();

0 commit comments

Comments
 (0)