You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (!array_intersect((array_keys($options)), ['normalizationContext', 'groups', 'context', 'value', 'denormalizationContext'])) {
39
42
// gracefully supports context as first, unnamed attribute argument if it cannot be confused with Doctrine-style options
40
43
$context = $options;
41
44
} else {
45
+
trigger_deprecation('symfony/serializer', '5.3', 'Passing an array of properties as first argument to "%s" is deprecated. Use named arguments instead.', __METHOD__);
46
+
42
47
// If at least one of the options match, it's likely to be Doctrine-style options. Search for the context inside:
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)));
trigger_deprecation('symfony/serializer', '5.3', 'Passing an array as first argument to "%s" is deprecated. Use named arguments instead.', __METHOD__);
Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Annotation/Groups.php
+11-2Lines changed: 11 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@
17
17
* Annotation class for @Groups().
18
18
*
19
19
* @Annotation
20
+
* @NamedArgumentConstructor
20
21
* @Target({"PROPERTY", "METHOD"})
21
22
*
22
23
* @author Kévin Dunglas <dunglas@gmail.com>
@@ -30,11 +31,19 @@ class Groups
30
31
private$groups;
31
32
32
33
/**
34
+
* @param string|string[] $groups
35
+
*
33
36
* @throws InvalidArgumentException
34
37
*/
35
-
publicfunction__construct(array$groups)
38
+
publicfunction__construct($groups)
36
39
{
37
-
if (isset($groups['value'])) {
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__);
Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Annotation/MaxDepth.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@
17
17
* Annotation class for @MaxDepth().
18
18
*
19
19
* @Annotation
20
+
* @NamedArgumentConstructor
20
21
* @Target({"PROPERTY", "METHOD"})
21
22
*
22
23
* @author Kévin Dunglas <dunglas@gmail.com>
@@ -30,11 +31,13 @@ class MaxDepth
30
31
private$maxDepth;
31
32
32
33
/**
33
-
* @param int|array $maxDepth
34
+
* @param int $maxDepth
34
35
*/
35
36
publicfunction__construct($maxDepth)
36
37
{
37
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
+
38
41
if (!isset($maxDepth['value'])) {
39
42
thrownewInvalidArgumentException(sprintf('Parameter of annotation "%s" should be set.', static::class));
trigger_deprecation('symfony/serializer', '5.3', 'Passing an array as first argument to "%s" is deprecated. Use named arguments instead.', __METHOD__);
40
+
38
41
if (!isset($serializedName['value'])) {
39
42
thrownewInvalidArgumentException(sprintf('Parameter of annotation "%s" should be set.', static::class));
0 commit comments