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

tests/app/Object/Post.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
class Post
88
{

tests/app/Object/Product.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 Symfony\Component\Serializer\Annotation\Groups;
88
use Symfony\Component\Serializer\Annotation\SerializedName;

tests/app/Object/User.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 DateTimeInterface;
88

tests/app/Response.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 ArrayIterator;
88
use Webmozart\Assert\Assert;

tests/src/Arch/DebugTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
arch('do not forget dumps in your production code')
6+
->expect(['trap', 'dd', 'dump', 'exit', 'die', 'print_r', 'var_dump', 'echo', 'print'])
7+
->not
8+
->toBeUsed();

tests/src/Bridge/Laravel/Providers/SerializerServiceProviderTest.php renamed to tests/src/Functional/Bridge/Laravel/Providers/SerializerServiceProviderTest.php

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

33
declare(strict_types=1);
44

5-
namespace WayOfDev\Serializer\Tests\Bridge\Laravel\Providers;
5+
namespace WayOfDev\Tests\Functional\Bridge\Laravel\Providers;
66

77
use Symfony\Component\Serializer\Serializer;
88
use Symfony\Component\Serializer\SerializerInterface;
@@ -12,7 +12,7 @@
1212
use WayOfDev\Serializer\Contracts\NormalizersRegistryInterface;
1313
use WayOfDev\Serializer\EncodersRegistry;
1414
use WayOfDev\Serializer\NormalizersRegistry;
15-
use WayOfDev\Serializer\Tests\TestCase;
15+
use WayOfDev\Tests\Functional\TestCase;
1616

1717
final class SerializerServiceProviderTest extends TestCase
1818
{

tests/src/EncodersRegistryTest.php renamed to tests/src/Functional/EncodersRegistryTest.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\Tests;
5+
namespace WayOfDev\Tests\Functional;
66

77
use PHPUnit\Framework\MockObject\Exception;
88
use Symfony\Component\Serializer\Encoder\CsvEncoder;

tests/src/Normalizers/RamseyUuidNormalizerTest.php renamed to tests/src/Functional/Normalizers/RamseyUuidNormalizerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
declare(strict_types=1);
44

5-
namespace WayOfDev\Serializer\Tests\Normalizers;
5+
namespace WayOfDev\Tests\Functional\Normalizers;
66

77
use PHPUnit\Framework\Attributes\DataProvider;
88
use Ramsey\Uuid\Uuid;
99
use Traversable;
10-
use WayOfDev\Serializer\App\Object\Author;
10+
use WayOfDev\App\Object\Author;
1111
use WayOfDev\Serializer\SerializerManager;
12-
use WayOfDev\Serializer\Tests\TestCase;
12+
use WayOfDev\Tests\Functional\TestCase;
1313

1414
use function preg_replace;
1515

tests/src/NormalizersRegistryTest.php renamed to tests/src/Functional/NormalizersRegistryTest.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\Tests;
5+
namespace WayOfDev\Tests\Functional;
66

77
use PHPUnit\Framework\MockObject\Exception;
88
use Symfony\Component\Serializer\Mapping\Loader\LoaderInterface;

tests/src/ResponseFactoryTest.php renamed to tests/src/Functional/ResponseFactoryTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
declare(strict_types=1);
44

5-
namespace WayOfDev\Serializer\Tests;
5+
namespace WayOfDev\Tests\Functional;
66

7-
use WayOfDev\Serializer\App\Item;
8-
use WayOfDev\Serializer\App\Object\Post;
9-
use WayOfDev\Serializer\App\Response;
7+
use WayOfDev\App\Item;
8+
use WayOfDev\App\Object\Post;
9+
use WayOfDev\App\Response;
1010
use WayOfDev\Serializer\ResponseFactory;
1111
use WayOfDev\Serializer\SerializerManager;
1212

@@ -48,7 +48,7 @@ public function it_creates_from_array_iterator(): void
4848
public function it_creates_response_from_array(): void
4949
{
5050
$responseFactory = new ResponseFactory(app(SerializerManager::class));
51-
$response = $responseFactory->fromArray(require __DIR__ . '/../app/array.php');
51+
$response = $responseFactory->fromArray(require __DIR__ . '/../../app/array.php');
5252

5353
self::assertEquals(200, $response->getStatusCode());
5454
self::assertEquals(

tests/src/SerializerManagerTest.php renamed to tests/src/Functional/SerializerManagerTest.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\Tests;
5+
namespace WayOfDev\Tests\Functional;
66

77
use PHPUnit\Framework\Attributes\DataProvider;
88
use Stringable;

tests/src/SerializerTest.php renamed to tests/src/Functional/SerializerTest.php

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

33
declare(strict_types=1);
44

5-
namespace WayOfDev\Serializer\Tests;
5+
namespace WayOfDev\Tests\Functional;
66

77
use DateTimeImmutable;
88
use DateTimeZone;
99
use PHPUnit\Framework\Attributes\DataProvider;
1010
use Traversable;
11-
use WayOfDev\Serializer\App\NestedObjects\City;
12-
use WayOfDev\Serializer\App\NestedObjects\Country;
13-
use WayOfDev\Serializer\App\Object\Post;
14-
use WayOfDev\Serializer\App\Object\Product;
15-
use WayOfDev\Serializer\App\Object\User;
11+
use WayOfDev\App\NestedObjects\City;
12+
use WayOfDev\App\NestedObjects\Country;
13+
use WayOfDev\App\Object\Post;
14+
use WayOfDev\App\Object\Product;
15+
use WayOfDev\App\Object\User;
1616
use WayOfDev\Serializer\Serializer;
1717
use WayOfDev\Serializer\SerializerManager;
1818

tests/src/TestCase.php renamed to tests/src/Functional/TestCase.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\Tests;
5+
namespace WayOfDev\Tests\Functional;
66

77
use Orchestra\Testbench\TestCase as Orchestra;
88
use WayOfDev\Serializer\Bridge\Laravel\Providers\SerializerServiceProvider;

tests/src/Pest.php

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

tests/src/Pest/ExampleTest.php

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

0 commit comments

Comments
 (0)