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
Copy file name to clipboardExpand all lines: UPGRADE-5.3.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
<<<<<<< HEAD
1
2
UPGRADE FROM 5.2 to 5.3
2
3
=======================
3
4
@@ -28,6 +29,11 @@ PhpunitBridge
28
29
29
30
* Deprecated the `SetUpTearDownTrait` trait, use original methods with "void" return typehint.
30
31
32
+
PropertyInfo
33
+
------------
34
+
35
+
* Deprecated the `Type::getCollectionKeyType()` and `Type::getCollectionValueType()` methods, use `Type::getCollectionKeyTypes()` and `Type::getCollectionValueTypes()` instead.
Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,12 @@
1
1
CHANGELOG
2
2
=========
3
3
4
+
5.3.0
5
+
-----
6
+
7
+
* Added support for multiple types for collection keys & values
8
+
* Deprecated the `Type::getCollectionKeyType()` and `Type::getCollectionValueType()` methods, use `Type::getCollectionKeyTypes()` and `Type::getCollectionValueTypes()` instead.
Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Tests/TypeTest.php
+72-1Lines changed: 72 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -12,15 +12,24 @@
12
12
namespaceSymfony\Component\PropertyInfo\Tests;
13
13
14
14
usePHPUnit\Framework\TestCase;
15
+
useSymfony\Bridge\PhpUnit\ExpectDeprecationTrait;
15
16
useSymfony\Component\PropertyInfo\Type;
16
17
17
18
/**
18
19
* @author Kévin Dunglas <dunglas@gmail.com>
19
20
*/
20
21
class TypeTest extends TestCase
21
22
{
22
-
publicfunctiontestConstruct()
23
+
use ExpectDeprecationTrait;
24
+
25
+
/**
26
+
* @group legacy
27
+
*/
28
+
publicfunctiontestLegacyConstruct()
23
29
{
30
+
$this->expectDeprecation('Since symfony/property-info 5.3: The "Symfony\Component\PropertyInfo\Type::getCollectionKeyType()" method is deprecated, use "getCollectionKeyTypes()" instead.');
31
+
$this->expectDeprecation('Since symfony/property-info 5.3: The "Symfony\Component\PropertyInfo\Type::getCollectionValueType()" method is deprecated, use "getCollectionValueTypes()" instead.');
$this->expectExceptionMessage('"Symfony\Component\PropertyInfo\Type::validateCollectionArgument()": Argument #5 ($collectionKeyType) must be of type "Symfony\Component\PropertyInfo\Type[]", "Symfony\Component\PropertyInfo\Type" or "null", "stdClass" given.');
112
+
113
+
newType('array', false, null, true, new \stdClass(), [newType('string')]);
$this->expectExceptionMessage('"Symfony\Component\PropertyInfo\Type::validateCollectionArgument()": Argument #5 ($collectionKeyType) must be of type "Symfony\Component\PropertyInfo\Type[]", "Symfony\Component\PropertyInfo\Type" or "null", array value "array" given.');
if (!\is_array($collectionArgument) && !$collectionArgumentinstanceof self) {
86
+
thrownew \TypeError(sprintf('"%s()": Argument #%d (%s) must be of type "%s[]", "%s" or "null", "%s" given.', __METHOD__, $argumentIndex, $argumentName, self::class, self::class, get_debug_type($collectionArgument)));
87
+
}
88
+
89
+
if (\is_array($collectionArgument)) {
90
+
foreach ($collectionArgumentas$type) {
91
+
if (!$typeinstanceof self) {
92
+
thrownew \TypeError(sprintf('"%s()": Argument #%d (%s) must be of type "%s[]", "%s" or "null", array value "%s" given.', __METHOD__, $argumentIndex, $argumentName, self::class, self::class, get_debug_type($collectionArgument)));
93
+
}
94
+
}
95
+
96
+
return$collectionArgument;
97
+
}
98
+
99
+
return [$collectionArgument];
74
100
}
75
101
76
102
/**
@@ -107,8 +133,33 @@ public function isCollection(): bool
107
133
* Gets collection key type.
108
134
*
109
135
* Only applicable for a collection type.
136
+
*
137
+
* @deprecated since Symfony 5.3, use "getCollectionKeyTypes()" instead
110
138
*/
111
139
publicfunctiongetCollectionKeyType(): ?self
140
+
{
141
+
trigger_deprecation('symfony/property-info', '5.3', 'The "%s()" method is deprecated, use "getCollectionKeyTypes()" instead.', __METHOD__);
142
+
143
+
$type = $this->getCollectionKeyTypes();
144
+
if (0 === \count($type)) {
145
+
returnnull;
146
+
}
147
+
148
+
if (\is_array($type)) {
149
+
[$type] = $type;
150
+
}
151
+
152
+
return$type;
153
+
}
154
+
155
+
/**
156
+
* Gets collection key types.
157
+
*
158
+
* Only applicable for a collection type.
159
+
*
160
+
* @return Type[]
161
+
*/
162
+
publicfunctiongetCollectionKeyTypes(): array
112
163
{
113
164
return$this->collectionKeyType;
114
165
}
@@ -117,8 +168,33 @@ public function getCollectionKeyType(): ?self
117
168
* Gets collection value type.
118
169
*
119
170
* Only applicable for a collection type.
171
+
*
172
+
* @deprecated since Symfony 5.3, use "getCollectionValueTypes()" instead
120
173
*/
121
174
publicfunctiongetCollectionValueType(): ?self
175
+
{
176
+
trigger_deprecation('symfony/property-info', '5.3', 'The "%s()" method is deprecated, use "getCollectionValueTypes()" instead.', __METHOD__);
0 commit comments