8000 support nullable array or collection · symfony/symfony@74ee588 · GitHub
[go: up one dir, main page]

Skip to content

Commit 74ee588

Browse files
committed
support nullable array or collection
1 parent 994e90c commit 74ee588

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ private function getDocBlockFromProperty($class, $property)
242242
* @param string $ucFirstProperty
243243
* @param int $type
244244
*
245-
* @return DocBlock|null
245+
* @return array|null
246246
*/
247247
private function getDocBlockFromMethod($class, $ucFirstProperty, $type)
248248
{
@@ -337,10 +337,10 @@ private function createType($docType, $nullable)
337337
$collectionValueType = null;
338338
} else {
339339
$collectionKeyType = new Type(Type::BUILTIN_TYPE_INT);
340-
$collectionValueType = new Type($phpType, false, $class);
340+
$collectionValueType = new Type($phpType, $nullable, $class);
341341
}
342342

343-
return new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, $collectionKeyType, $collectionValueType);
343+
return new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, $collectionKeyType, $collectionValueType);
344344
}
345345

346346
return new Type($phpType, $nullable, $class);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function typesProvider()
6868
array('d', array(new Type(Type::BUILTIN_TYPE_BOOL)), null, null),
6969
array('e', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_RESOURCE))), null, null),
7070
array('f', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))), null, null),
71+
array('g', array(new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)), 'Nullable array.', null),
7172
array('donotexist', null, null, null),
7273
array('staticGetter', null, null, null),
7374
array('staticSetter', null, null, null),

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function testGetProperties()
3838
'parent',
3939
'collection',
4040
'B',
41+
'g',
4142
'foo',
4243
'foo2',
4344
'foo3',

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ class Dummy extends ParentDummy
5151
*/
5252
public $B;
5353

54+
/**
55+
* Nullable array.
56+
*
57+
* @var array|null
58+
*/
59+
public $g;
60+
5461
public static function getStatic()
5562
{
5663
}

0 commit comments

Comments
 (0)
0