8000 Bump Symfony version to 5.4.22 · symfony/symfony@bbcbcc6 · GitHub
[go: up one dir, main page]

Skip to content

Commit bbcbcc6

Browse files
fabpotMudrakIvan
authored andcommitted
Bump Symfony version to 5.4.22
+ fix phpDocExtractor nullable array value type merge 5.4 to ticket_49555 fix test fixture + fix phpDocExtractor nullable array value type merge 5.4 to ticket_49555
1 parent e7002e5 commit bbcbcc6

File tree

5 files changed

+31
-25
lines changed

5 files changed

+31
-25
lines changed

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
7878
*/
7979
private static $freshCache = [];
8080

81-
public const VERSION = '5.4.21';
82-
public const VERSION_ID = 50421;
81+
public const VERSION = '5.4.22-DEV';
82+
public const VERSION_ID = 50422;
8383
public const MAJOR_VERSION = 5;
8484
public const MINOR_VERSION = 4;
85-
public const RELEASE_VERSION = 21;
86-
public const EXTRA_VERSION = '';
85+
public const RELEASE_VERSION = 22;
86+
public const EXTRA_VERSION = 'DEV';
8787

8888
public const END_OF_MAINTENANCE = '11/2024';
8989
public const END_OF_LIFE = '11/2025';

src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function testExtractCollection($property, array $type = null, $shortDescr
169169
public static function provideCollectionTypes()
170170
{
171171
return [
172-
['iteratorCollection', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Iterator', true, null, new Type(Type::BUILTIN_TYPE_STRING))], null, null],
172+
['iteratorCollection', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Iterator', true, [new Type(Type::BUILTIN_TYPE_STRING), new Type(Type::BUILTIN_TYPE_INT)], new Type(Type::BUILTIN_TYPE_STRING))], null, null],
173173
['iteratorCollectionWithKey', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Iterator', true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING))], null, null],
174174
[
175175
'nestedIterators',
@@ -265,6 +265,8 @@ public static function typesWithCustomPrefixesProvider()
265265
['i', [new Type(Type::BUILTIN_TYPE_STRING, true), new Type(Type::BUILTIN_TYPE_INT, true)], null, null],
266266
['j', [new Type(Type::BUILTIN_TYPE_OBJECT, true, 'DateTime')], null, null],
267267
['nullableCollectionOfNonNullableElements', [new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_INT, false))], null, null],
268+
['nonNullableCollectionOfNullableElements', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_INT, true))], null, null],
269+
['nullableCollectionOfMultipleNonNullableElementTypes', [new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true, new Type(Type::BUILTIN_TYPE_INT), [new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)])], null, null],
268270
['donotexist', null, null, null],
269271
['staticGetter', null, null, null],
270272
['staticSetter', null, null, null],

src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public function testGetProperties()
6262
'i',
6363
'j',
6464
'nullableCollectionOfNonNullableElements',
65+
'nonNullableCollectionOfNullableElements',
66+
'nullableCollectionOfMultipleNonNullableElementTypes',
6567
'emptyVar',
6668
'iteratorCollection',
6769
'iteratorCollectionWithKey',
@@ -124,6 +126,8 @@ public function testGetPropertiesWithCustomPrefixes()
124126
'i',
125127
'j',
126128
'nullableCollectionOfNonNullableElements',
129+
'nonNullableCollectionOfNullableElements',
130+
'nullableCollectionOfMultipleNonNullableElementTypes',
127131
'emptyVar',
128132
'iteratorCollection',
129133
'iteratorCollectionWithKey',
@@ -175,6 +179,8 @@ public function testGetPropertiesWithNoPrefixes()
175179
'i',
176180
'j',
177181
'nullableCollectionOfNonNullableElements',
182+
'nonNullableCollectionOfNullableElements',
183+
'nullableCollectionOfMultipleNonNullableElementTypes',
178184
'emptyVar',
179185
'iteratorCollection',
180186
'iteratorCollectionWithKey',

src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ class Dummy extends ParentDummy
9898
*/
9999
public $nullableCollectionOfNonNullableElements;
100100

101+
/**
102+
* @var array<null|int>
103+
*/
104+
public $nonNullableCollectionOfNullableElements;
105+
106+
/**
107+
* @var null|array<int|string>
108+
*/
109+
public $nullableCollectionOfMultipleNonNullableElementTypes;
110+
101111
/**
102112
* @var array
103113
*/

src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -115,43 +115,31 @@ private function createType(DocType $type, bool $nullable, string $docType = nul
115115

116116
[$phpType, $class] = $this->getPhpTypeAndClass((string) $fqsen);
117117

118-
$key = $this->getTypes($type->getKeyType());
119-
$value = $this->getTypes($type->getValueType());
118+
$keys = $this->getTypes($type->getKeyType());
119+
$values = $this->getTypes($type->getValueType());
120120

121-
// More than 1 type returned means it is a Compound type, which is
122-
// not handled by Type, so better use a null value.
123-
$key = 1 === \count($key) ? $key[0] : null;
124-
$value = 1 === \count($value) ? $value[0] : null;
125-
126-
return new Type($phpType, $nullable, $class, true, $key, $value);
121+
return new Type($phpType, $nullable, $class, true, $keys, $values);
127122
}
128123

129124
// Cannot guess
130125
if (!$docType || 'mixed' === $docType) {
131126
return null;
132127
}
133128

134-
if (str_ends_with($docType, '[]')) {
129+
if (str_ends_with($docType, '[]') && $type instanceof Array_) {
135130
$collectionKeyType = new Type(Type::BUILTIN_TYPE_INT);
136-
$collectionValueType = $this->createType($type, false, substr($docType, 0, -2));
131+
$collectionValueTypes = $this->getTypes($type->getValueType());
137132

138-
return new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, $collectionKeyType, $collectionValueType);
133+
return new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, $collectionKeyType, $collectionValueTypes);
139134
}
140135

141136
if ((str_starts_with($docType, 'list<') || str_starts_with($docType, 'array<')) && $type instanceof Array_) {
142137
// array<value> is converted to x[] which is handled above
143138
// so it's only necessary to handle array<key, value> here
144-
$collectionKeyType = $this->getTypes($type->getKeyType())[0];
145-
139+
$collectionKeyTypes = $this->getTypes($type->getKeyType());
146140
$collectionValueTypes = $this->getTypes($type->getValueType());
147-
if (1 != \count($collectionValueTypes)) {
148-
// the Type class does not support union types yet, so assume that no type was defined
149-
$collectionValueType = null;
150-
} else {
151-
$collectionValueType = $collectionValueTypes[0];
152-
}
153141

154-
return new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, $collectionKeyType, $collectionValueType);
142+
return new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, $collectionKeyTypes, $collectionValueTypes);
155143
}
156144

157145
$docType = $this->normalizeType($docType);

0 commit comments

Comments
 (0)
0