Skip to content

Commit 592166d

Browse files
committed
Merge branch '1.15.x' into 2.0.x
2 parents 8e66530 + be34138 commit 592166d

18 files changed

Lines changed: 363 additions & 81 deletions

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
dependencies:
1717
- "locked"
1818
php-version:
19-
- "8.4"
19+
- "8.5"
2020
operating-system:
2121
- "ubuntu-latest"
2222

.github/workflows/coding-standard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
dependencies:
2121
- "locked"
2222
php-version:
23-
- "8.4"
23+
- "8.5"
2424
operating-system:
2525
- "ubuntu-latest"
2626

.github/workflows/mutation-tests-diff.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
dependencies:
1717
- "locked"
1818
php-version:
19-
- "8.4"
19+
- "8.5"
2020
operating-system:
2121
- "ubuntu-latest"
2222

.github/workflows/mutation-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
dependencies:
2121
- "locked"
2222
php-version:
23-
- "8.4"
23+
- "8.5"
2424
operating-system:
2525
- "ubuntu-latest"
2626

.github/workflows/phpstan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
dependencies:
2121
- "locked"
2222
php-version:
23-
- "8.4"
23+
- "8.5"
2424
operating-system:
2525
- "ubuntu-latest"
2626

.github/workflows/unit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ jobs:
2828
- "ubuntu-latest"
2929
include:
3030
- dependencies: "locked"
31-
php-version: "8.4"
31+
php-version: "8.5"
3232
operating-system: "ubuntu-latest"
3333
- dependencies: "locked"
34-
php-version: "8.4"
34+
php-version: "8.5"
3535
operating-system: "windows-latest"
3636
- dependencies: "lowest"
3737
php-version: "8.5"

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,42 @@ final class AnotherDto
308308
> [!WARNING]
309309
> Circular references are not supported and will result in an exception.
310310
311+
#### Inline
312+
313+
The `InlineNormalizer` allows you to define normalization and denormalization logic directly via closures.
314+
This is useful for simple value objects or when you don't want to create a separate normalizer class.
315+
316+
```php
317+
use Patchlevel\Hydrator\Normalizer\InlineNormalizer;
318+
319+
#[InlineNormalizer(
320+
normalize: static function (self $object): string {
321+
return $object->toString();
322+
},
323+
denormalize: static function (string $value): self {
324+
return new self($value);
325+
},
326+
)]
327+
final class Email
328+
{
329+
public function __construct(
330+
private string $value
331+
) {}
332+
333+
public function toString(): string
334+
{
335+
return $this->value;
336+
}
337+
}
338+
```
339+
340+
> [!NOTE]
341+
> Closures in attributes can only be used since PHP 8.5, therefore this normalizer can only be used with PHP 8.5.
342+
343+
> [!TIP]
344+
> If you want to handle `null` values within your closures, you can set the `passNull` option to `true`.
345+
> By default, `null` values are not passed to the closures and are returned as `null` directly.
346+
311347
### Custom Normalizer
312348

313349
Since we only offer normalizers for PHP native things,
@@ -714,3 +750,11 @@ To remove personal data, you need only remove the key from the store.
714750
```php
715751
$cipherKeyStore->remove('foo-id');
716752
```
753+
754+
755+
## Contributing
756+
757+
We are open to contributions as long as they are in line with
758+
our [BC-Policy](https://event-sourcing.patchlevel.io/latest/our-backward-compatibility-promise/).
759+
760+
Also note that the `composer.lock` is always generated with the newest supported PHP version as this is the version our tools run in the CI.

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
"symfony/type-info": "^7.3.0 || ^8.0.0"
2727
},
2828
"require-dev": {
29-
"infection/infection": "^0.32.0",
29+
"infection/infection": "^0.32.4",
3030
"patchlevel/coding-standard": "^1.3.0",
31-
"phpat/phpat": "^0.12.0",
32-
"phpbench/phpbench": "^1.2.15",
33-
"phpstan/phpstan": "^2.1.32",
34-
"phpstan/phpstan-phpunit": "^2.0.8",
35-
"phpunit/phpunit": "^11.5.17",
31+
"phpat/phpat": "^0.12.2",
32+
"phpbench/phpbench": "^1.4.3",
33+
"phpstan/phpstan": "^2.1.39",
34+
"phpstan/phpstan-phpunit": "^2.0.15",
35+
"phpunit/phpunit": "^11.5.53",
3636
"symfony/var-dumper": "^5.4.29 || ^6.4.0 || ^7.0.0 || ^8.0.0"
3737
},
3838
"config": {

composer.lock

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan-baseline.neon

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,6 @@ parameters:
120120
count: 2
121121
path: tests/Unit/Normalizer/ArrayNormalizerTest.php
122122

123-
-
124-
message: '#^Parameter \#1 \$normalizer of class Patchlevel\\Hydrator\\Normalizer\\ArrayNormalizer constructor expects Patchlevel\\Hydrator\\Normalizer\\Normalizer, PHPUnit\\Framework\\MockObject\\MockObject given\.$#'
125-
identifier: argument.type
126-
count: 1
127-
path: tests/Unit/Normalizer/ArrayNormalizerTest.php
128-
129123
-
130124
message: '#^Cannot cast mixed to int\.$#'
131125
identifier: cast.int
@@ -137,9 +131,3 @@ parameters:
137131
identifier: cast.string
138132
count: 2
139133
path: tests/Unit/Normalizer/ArrayShapeNormalizerTest.php
140-
141-
-
142-
message: '#^Parameter \#1 \$normalizerMap of class Patchlevel\\Hydrator\\Normalizer\\ArrayShapeNormalizer constructor expects array\<Patchlevel\\Hydrator\\Normalizer\\Normalizer\>, array\<string, PHPUnit\\Framework\\MockObject\\MockObject\> given\.$#'
143-
identifier: argument.type
144-
count: 1
145-
path: tests/Unit/Normalizer/ArrayShapeNormalizerTest.php

0 commit comments

Comments
 (0)