Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4db6d56

Browse files
[Serializer] add union types
1 parentfd0566c commit4db6d56

File tree

57 files changed

+143
-410
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+143
-410
lines changed

‎src/Symfony/Component/Serializer/Annotation/Context.php‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class Context
3535
*
3636
* @throws InvalidArgumentException
3737
*/
38-
publicfunction__construct(array$options = [],array$context = [],array$normalizationContext = [],array$denormalizationContext = [],$groups = [])
38+
publicfunction__construct(array$options = [],array$context = [],array$normalizationContext = [],array$denormalizationContext = [],string|array$groups = [])
3939
{
4040
if (!$context) {
4141
if (!array_intersect((array_keys($options)), ['normalizationContext','groups','context','value','denormalizationContext'])) {
@@ -48,9 +48,6 @@ public function __construct(array $options = [], array $context = [], array $nor
4848
$context =$options['value'] ??$options['context'] ?? [];
4949
}
5050
}
51-
if (!\is_string($groups) && !\is_array($groups)) {
52-
thrownew \TypeError(sprintf('"%s": Expected parameter $groups to be a string or an array of strings, got "%s".',__METHOD__,get_debug_type($groups)));
53-
}
5451

5552
$normalizationContext =$options['normalizationContext'] ??$normalizationContext;
5653
$denormalizationContext =$options['denormalizationContext'] ??$denormalizationContext;

‎src/Symfony/Component/Serializer/Annotation/DiscriminatorMap.php‎

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,11 @@
2525
#[\Attribute(\Attribute::TARGET_CLASS)]
2626
class DiscriminatorMap
2727
{
28-
/**
29-
* @var string
30-
*/
3128
private$typeProperty;
32-
33-
/**
34-
* @var array
35-
*/
3629
private$mapping;
3730

38-
/**
39-
* @param string $typeProperty
40-
*
41-
* @throws InvalidArgumentException
42-
*/
43-
publicfunction__construct($typeProperty,array$mapping =null)
31+
publicfunction__construct(string$typeProperty,array$mapping)
4432
{
45-
if (\is_array($typeProperty)) {
46-
trigger_deprecation('symfony/serializer','5.3','Passing an array as first argument to "%s" is deprecated. Use named arguments instead.',__METHOD__);
47-
48-
$mapping =$typeProperty['mapping'] ??null;
49-
$typeProperty =$typeProperty['typeProperty'] ??null;
50-
}elseif (!\is_string($typeProperty)) {
51-
thrownew \TypeError(sprintf('"%s": Argument $typeProperty was expected to be a string or array, got "%s".',__METHOD__,get_debug_type($typeProperty)));
52-
}
53-
5433
if (empty($typeProperty)) {
5534
thrownewInvalidArgumentException(sprintf('Parameter "typeProperty" of annotation "%s" cannot be empty.',static::class));
5635
}

‎src/Symfony/Component/Serializer/Annotation/Groups.php‎

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,25 @@ class Groups
3232

3333
/**
3434
* @param string|string[] $groups
35-
*
36-
* @throws InvalidArgumentException
3735
*/
38-
publicfunction__construct($groups)
36+
publicfunction__construct(string|array$groups)
3937
{
40-
if (\is_string($groups)) {
41-
$groups = (array)$groups;
42-
}elseif (!\is_array($groups)) {
43-
thrownew \TypeError(sprintf('"%s": Parameter $groups is expected to be a string or an array of strings, got "%s".',__METHOD__,get_debug_type($groups)));
44-
}elseif (isset($groups['value'])) {
45-
trigger_deprecation('symfony/serializer','5.3','Passing an array of properties as first argument to "%s" is deprecated. Use named arguments instead.',__METHOD__);
38+
$groups = (array)$groups;
4639

47-
$groups = (array)$groups['value'];
48-
}
4940
if (empty($groups)) {
5041
thrownewInvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.',static::class));
5142
}
5243

5344
foreach ($groupsas$group) {
54-
if (!\is_string($group)) {
55-
thrownewInvalidArgumentException(sprintf('Parameter of annotation "%s" must be a string or an array of strings.',static::class));
45+
if (!\is_string($group) ||'' ===$group) {
46+
thrownewInvalidArgumentException(sprintf('Parameter of annotation "%s" must be a string or an array ofnon-emptystrings.',static::class));
5647
}
5748
}
5849

5950
$this->groups =$groups;
6051
}
6152

6253
/**
63-
* Gets groups.
64-
*
6554
* @return string[]
6655
*/
6756
publicfunctiongetGroups()

‎src/Symfony/Component/Serializer/Annotation/MaxDepth.php‎

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,11 @@
2525
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
2626
class MaxDepth
2727
{
28-
/**
29-
* @var int
30-
*/
3128
private$maxDepth;
3229

33-
/**
34-
* @param int $maxDepth
35-
*/
36-
publicfunction__construct($maxDepth)
30+
publicfunction__construct(int$maxDepth)
3731
{
38-
if (\is_array($maxDepth)) {
39-
trigger_deprecation('symfony/serializer','5.3','Passing an array as first argument to "%s" is deprecated. Use named arguments instead.',__METHOD__);
40-
41-
if (!isset($maxDepth['value'])) {
42-
thrownewInvalidArgumentException(sprintf('Parameter of annotation "%s" should be set.',static::class));
43-
}
44-
$maxDepth =$maxDepth['value'];
45-
}
46-
47-
if (!\is_int($maxDepth) ||$maxDepth <=0) {
32+
if ($maxDepth <=0) {
4833
thrownewInvalidArgumentException(sprintf('Parameter of annotation "%s" must be a positive integer.',static::class));
4934
}
5035

‎src/Symfony/Component/Serializer/Annotation/SerializedName.php‎

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,11 @@
2525
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
2626
finalclass SerializedName
2727
{
28-
/**
29-
* @var string
30-
*/
3128
private$serializedName;
3229

33-
/**
34-
* @param string $serializedName
35-
*/
36-
publicfunction__construct($serializedName)
30+
publicfunction__construct(string$serializedName)
3731
{
38-
if (\is_array($serializedName)) {
39-
trigger_deprecation('symfony/serializer','5.3','Passing an array as first argument to "%s" is deprecated. Use named arguments instead.',__METHOD__);
40-
41-
if (!isset($serializedName['value'])) {
42-
thrownewInvalidArgumentException(sprintf('Parameter of annotation "%s" should be set.',static::class));
43-
}
44-
$serializedName =$serializedName['value'];
45-
}
46-
47-
if (!\is_string($serializedName) ||empty($serializedName)) {
32+
if (empty($serializedName)) {
4833
thrownewInvalidArgumentException(sprintf('Parameter of annotation "%s" must be a non-empty string.',static::class));
4934
}
5035

‎src/Symfony/Component/Serializer/CacheWarmer/CompiledClassMetadataCacheWarmer.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(array $classesToCompile, ClassMetadataFactoryInterfa
4040
/**
4141
* {@inheritdoc}
4242
*/
43-
publicfunctionwarmUp($cacheDir)
43+
publicfunctionwarmUp(string$cacheDir)
4444
{
4545
$metadatas = [];
4646

‎src/Symfony/Component/Serializer/Encoder/ChainEncoder.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(array $encoders = [])
3535
/**
3636
* {@inheritdoc}
3737
*/
38-
finalpublicfunctionencode($data,string$format,array$context = [])
38+
finalpublicfunctionencode(mixed$data,string$format,array$context = [])
3939
{
4040
return$this->getEncoder($format,$context)->encode($data,$format,$context);
4141
}

‎src/Symfony/Component/Serializer/Encoder/CsvEncoder.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct(array $defaultContext = [])
5858
/**
5959
* {@inheritdoc}
6060
*/
61-
publicfunctionencode($data,string$format,array$context = [])
61+
publicfunctionencode(mixed$data,string$format,array$context = [])
6262
{
6363
$handle =fopen('php://temp,','w+');
6464

‎src/Symfony/Component/Serializer/Encoder/EncoderInterface.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface EncoderInterface
2929
*
3030
* @throws UnexpectedValueException
3131
*/
32-
publicfunctionencode($data,string$format,array$context = []);
32+
publicfunctionencode(mixed$data,string$format,array$context = []);
3333

3434
/**
3535
* Checks whether the serializer can encode to given format.

‎src/Symfony/Component/Serializer/Encoder/JsonEncode.php‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ public function __construct(array $defaultContext = [])
3232
}
3333

3434
/**
35-
* Encodes PHP data to a JSON string.
36-
*
3735
* {@inheritdoc}
3836
*/
39-
publicfunctionencode($data,string$format,array$context = [])
37+
publicfunctionencode(mixed$data,string$format,array$context = [])
4038
{
4139
$options =$context[self::OPTIONS] ??$this->defaultContext[self::OPTIONS];
4240

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp