support nullable array or collection
This commit is contained in:
parent
994e90c129
commit
74ee588924
@ -242,7 +242,7 @@ class PhpDocExtractor implements PropertyDescriptionExtractorInterface, Property
|
|||||||
* @param string $ucFirstProperty
|
* @param string $ucFirstProperty
|
||||||
* @param int $type
|
* @param int $type
|
||||||
*
|
*
|
||||||
* @return DocBlock|null
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
private function getDocBlockFromMethod($class, $ucFirstProperty, $type)
|
private function getDocBlockFromMethod($class, $ucFirstProperty, $type)
|
||||||
{
|
{
|
||||||
@ -337,10 +337,10 @@ class PhpDocExtractor implements PropertyDescriptionExtractorInterface, Property
|
|||||||
$collectionValueType = null;
|
$collectionValueType = null;
|
||||||
} else {
|
} else {
|
||||||
$collectionKeyType = new Type(Type::BUILTIN_TYPE_INT);
|
$collectionKeyType = new Type(Type::BUILTIN_TYPE_INT);
|
||||||
$collectionValueType = new Type($phpType, false, $class);
|
$collectionValueType = new Type($phpType, $nullable, $class);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, $collectionKeyType, $collectionValueType);
|
return new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, $collectionKeyType, $collectionValueType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Type($phpType, $nullable, $class);
|
return new Type($phpType, $nullable, $class);
|
||||||
|
@ -68,6 +68,7 @@ class PhpDocExtractorTest extends TestCase
|
|||||||
array('d', array(new Type(Type::BUILTIN_TYPE_BOOL)), null, null),
|
array('d', array(new Type(Type::BUILTIN_TYPE_BOOL)), null, null),
|
||||||
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),
|
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),
|
||||||
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),
|
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),
|
||||||
|
array('g', array(new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)), 'Nullable array.', null),
|
||||||
array('donotexist', null, null, null),
|
array('donotexist', null, null, null),
|
||||||
array('staticGetter', null, null, null),
|
array('staticGetter', null, null, null),
|
||||||
array('staticSetter', null, null, null),
|
array('staticSetter', null, null, null),
|
||||||
|
@ -38,6 +38,7 @@ class ReflectionExtractorTest extends TestCase
|
|||||||
'parent',
|
'parent',
|
||||||
'collection',
|
'collection',
|
||||||
'B',
|
'B',
|
||||||
|
'g',
|
||||||
'foo',
|
'foo',
|
||||||
'foo2',
|
'foo2',
|
||||||
'foo3',
|
'foo3',
|
||||||
|
@ -51,6 +51,13 @@ class Dummy extends ParentDummy
|
|||||||
*/
|
*/
|
||||||
public $B;
|
public $B;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nullable array.
|
||||||
|
*
|
||||||
|
* @var array|null
|
||||||
|
*/
|
||||||
|
public $g;
|
||||||
|
|
||||||
public static function getStatic()
|
public static function getStatic()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user