Skip to content

Commit b05333d

Browse files
committed
feat: support for laravel 11.x and symfony 7.x
1 parent ca5ef98 commit b05333d

25 files changed

+98
-72
lines changed

README.md

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
1-
<br>
2-
3-
<div align="center">
4-
<img width="456" src="https://raw.githubusercontent.com/wayofdev/laravel-symfony-serializer/master/assets/logo.gh-light-mode-only.png#gh-light-mode-only">
5-
<img width="456" src="https://raw.githubusercontent.com/wayofdev/laravel-symfony-serializer/master/assets/logo.gh-dark-mode-only.png#gh-dark-mode-only">
6-
</div>
7-
8-
<br>
9-
10-
<br>
1+
<p align="center">
2+
<br>
3+
<a href="https://wayof.dev" target="_blank">
4+
<picture>
5+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wayofdev/.github/master/assets/logo.gh-dark-mode-only.png">
6+
<img width="400" src="https://raw.githubusercontent.com/wayofdev/.github/master/assets/logo.gh-light-mode-only.png" alt="WayOfDev Logo">
7+
</picture>
8+
</a>
9+
<br>
10+
</p>
11+
12+
<p align="center">
13+
<strong>Build</strong><br>
14+
<a href="https://github.com/wayofdev/laravel-symfony-serializer/actions" target="_blank"><img alt="Build Status" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fwayofdev%2Flaravel-symfony-serializer%2Fbadge&style=flat-square&label=github%20actions"/></a>
15+
</p>
16+
<p align="center">
17+
<strong>Project</strong><br>
18+
<a href="https://packagist.org/packages/wayofdev/laravel-symfony-serializer" target="_blank"><img src="https://img.shields.io/packagist/dt/wayofdev/laravel-symfony-serializer?&style=flat-square" alt="Total Downloads"></a>
19+
<a href="https://packagist.org/packages/wayofdev/laravel-symfony-serializer" target="_blank"><img src="https://img.shields.io/packagist/v/wayofdev/laravel-symfony-serializer?&style=flat-square" alt="Latest Stable Version"></a>
20+
<a href="https://packagist.org/packages/wayofdev/laravel-symfony-serializer" target="_blank"><img alt="Commits since latest release" src="https://img.shields.io/github/commits-since/wayofdev/laravel-symfony-serializer/latest?style=flat-square"></a>
21+
<a href="https://packagist.org/packages/wayofdev/laravel-symfony-serializer" target="_blank"><img alt="PHP Version Require" src="https://poser.pugx.org/wayofdev/laravel-symfony-serializer/require/php?style=flat-square"></a>
22+
</p>
23+
<p align="center">
24+
<strong>Quality</strong><br>
25+
<a href="https://app.codecov.io/gh/wayofdev/laravel-symfony-serializer" target="_blank"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/wayofdev/laravel-symfony-serializer?style=flat-square&logo=codecov"></a>
26+
<a href="https://dashboard.stryker-mutator.io/reports/github.com/wayofdev/laravel-symfony-serializer/master" target="_blank"><img alt="Mutation testing badge" src="https://img.shields.io/endpoint?style=flat-square&label=mutation%20score&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fwayofdev%2Flaravel-symfony-serializer%2Fmaster"></a>
27+
<a href=""><img src="https://img.shields.io/badge/phpstan%20level-6%20of%209-yellowgreen?style=flat-square" alt="PHP Stan Level 6 of 9"></a>
28+
</p>
29+
<p align="center">
30+
<strong>Community</strong><br>
31+
<a href="https://discord.gg/CE3TcCC5vr" target="_blank"><img alt="Discord" src="https://img.shields.io/discord/1228506758562058391?style=flat-square&logo=discord&labelColor=7289d9&logoColor=white&color=39456d"></a>
32+
<a href="https://x.com/intent/follow?screen_name=wayofdev" target="_blank"><img alt="Follow on Twitter (X)" src="https://img.shields.io/badge/-Follow-black?style=flat-square&logo=X"></a>
33+
</p>
1134

12-
<div align="center">
13-
<a href="https://github.com/wayofdev/laravel-symfony-serializer/actions"><img alt="Build Status" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fwayofdev%2Flaravel-symfony-serializer%2Fbadge&style=flat-square"/></a>
14-
<a href="https://packagist.org/packages/wayofdev/laravel-symfony-serializer"><img src="https://img.shields.io/packagist/dt/wayofdev/laravel-symfony-serializer?&style=flat-square" alt="Total Downloads"></a>
15-
<a href="https://packagist.org/packages/wayofdev/laravel-symfony-serializer"><img src="https://img.shields.io/packagist/v/wayofdev/laravel-symfony-serializer?&style=flat-square" alt="Latest Stable Version"></a>
16-
<a href="https://packagist.org/packages/wayofdev/laravel-symfony-serializer"><img src="https://img.shields.io/packagist/l/wayofdev/laravel-symfony-serializer?style=flat-square&color=blue" alt="Software License"/></a>
17-
<a href="https://packagist.org/packages/wayofdev/laravel-symfony-serializer"><img alt="Commits since latest release" src="https://img.shields.io/github/commits-since/wayofdev/laravel-symfony-serializer/latest?style=flat-square"></a>
18-
</div>
1935
<br>
2036

2137
# Laravel Symfony Serializer

composer-require-checker.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"Illuminate\\Support\\ServiceProvider",
44
"Illuminate\\Console\\Command",
55
"config_path",
6-
"Symfony\\Component\\Yaml\\Dumper"
6+
"Symfony\\Component\\Yaml\\Dumper",
7+
"Illuminate\\Http\\Response"
78
]
89
}

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
},
3232
"require": {
3333
"php": "^8.2",
34-
"doctrine/annotations": "^2.0",
3534
"illuminate/http": "^11.0",
3635
"symfony/property-access": "^7.1",
3736
"symfony/serializer": "^7.1",
@@ -68,8 +67,8 @@
6867
},
6968
"autoload-dev": {
7069
"psr-4": {
71-
"WayOfDev\\Serializer\\App\\": "tests/app/",
72-
"WayOfDev\\Serializer\\Tests\\": "tests/src/"
70+
"WayOfDev\\App\\": "tests/app/",
71+
"WayOfDev\\Tests\\": "tests/src/"
7372
}
7473
},
7574
"config": {

infection.json.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"report": "master"
77
}
88
},
9-
"minCoveredMsi": 55,
10-
"minMsi": 55,
9+
"minCoveredMsi": 90,
10+
"minMsi": 85,
1111
"phpUnit": {
1212
"configDir": "./"
1313
},

src/Config.php

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

55
namespace WayOfDev\Serializer;
66

7-
use Doctrine\Common\Annotations\AnnotationReader;
8-
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
7+
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
98
use Symfony\Component\Serializer\Mapping\Loader\LoaderInterface;
109
use WayOfDev\Serializer\Contracts\ConfigRepository;
1110
use WayOfDev\Serializer\Exceptions\MissingRequiredAttributes;
@@ -63,6 +62,10 @@ public function encoders(): array
6362

6463
public function metadataLoader(): LoaderInterface
6564
{
66-
return new AnnotationLoader(new AnnotationReader());
65+
if (! empty($this->config['metadataLoader'])) {
66+
return $this->config['metadataLoader'];
67+
}
68+
69+
return new AttributeLoader();
6770
}
6871
}

src/Normalizers/RamseyUuidNormalizer.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace WayOfDev\Serializer\Normalizers;
66

7+
use ArrayObject;
78
use InvalidArgumentException;
89
use Ramsey\Uuid\Uuid;
910
use Ramsey\Uuid\UuidInterface;
@@ -18,14 +19,16 @@
1819
final class RamseyUuidNormalizer implements NormalizerInterface, DenormalizerInterface
1920
{
2021
/**
21-
* @phan-param-override UuidInterface $object
22+
* @param UuidInterface $object
23+
*
24+
* @psalm-suppress MoreSpecificImplementedParamType
2225
*/
23-
public function normalize(mixed $object, ?string $format = null, array $context = []): string
26+
public function normalize(mixed $object, ?string $format = null, array $context = []): array|string|int|float|bool|ArrayObject|null
2427
{
2528
return $object->toString();
2629
}
2730

28-
public function supportsNormalization(mixed $data, ?string $format = null): bool
31+
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
2932
{
3033
return $data instanceof UuidInterface;
3134
}
@@ -41,8 +44,18 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a
4144
}
4245
}
4346

44-
public function supportsDenormalization(mixed $data, string $type, ?string $format = null): bool
47+
public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool
4548
{
4649
return is_string($data) && is_a($type, UuidInterface::class, true) && Uuid::isValid($data);
4750
}
51+
52+
/**
53+
* @return array<class-string|'*'|'object'|string, bool|null>
54+
*/
55+
public function getSupportedTypes(?string $format): array
56+
{
57+
return [
58+
UuidInterface::class => true,
59+
];
60+
}
4861
}

tests/app/Item.php

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

33
declare(strict_types=1);
44

5-
namespace WayOfDev\Serializer\App;
5+
namespace WayOfDev\App;
66

77
use Ramsey\Uuid\Uuid;
88
use Ramsey\Uuid\UuidInterface;

tests/app/NestedObjects/City.php

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

33
declare(strict_types=1);
44

5-
namespace WayOfDev\Serializer\App\NestedObjects;
5+
namespace WayOfDev\App\NestedObjects;
66

77
use DateTimeZone;
88
use JsonSerializable;

tests/app/NestedObjects/Country.php

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

33
declare(strict_types=1);
44

5-
namespace WayOfDev\Serializer\App\NestedObjects;
5+
namespace WayOfDev\App\NestedObjects;
66

77
final class Country
88
{

tests/app/Object/Author.php

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

33
declare(strict_types=1);
44

5-
namespace WayOfDev\Serializer\App\Object;
5+
namespace WayOfDev\App\Object;
66

77
use Ramsey\Uuid\UuidInterface;
88

0 commit comments

Comments
 (0)