mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-17 17:47:13 +00:00
Handle more PHPDoc type keyworks (#23)
* Added advanced PHPDoc type keyworks * Fixed typed keywords
This commit is contained in:
@@ -37,7 +37,14 @@ class Collection extends \ArrayObject
|
||||
protected static $keywords = array(
|
||||
'string', 'int', 'integer', 'bool', 'boolean', 'float', 'double',
|
||||
'object', 'mixed', 'array', 'resource', 'void', 'null', 'scalar',
|
||||
'callback', 'callable', 'false', 'true', 'self', '$this', 'static'
|
||||
'callback', 'callable', 'false', 'true', 'self', '$this', 'static',
|
||||
'array-key', 'number', 'iterable', 'pure-callable', 'closed-resource',
|
||||
'open-resource', 'positive-int', 'negative-int', 'non-positive-int',
|
||||
'non-negative-int', 'non-zero-int', 'non-empty-array', 'list',
|
||||
'non-empty-list', 'key-of', 'value-of', 'template-type', 'class-string',
|
||||
'callable-string', 'numeric-string', 'non-empty-string',
|
||||
'non-falsy-string', 'literal-string', 'lowercase-string', 'never',
|
||||
'never-return', 'never-returns', 'no-return', 'int-mask', 'int-mask-of'
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -194,7 +201,7 @@ class Collection extends \ArrayObject
|
||||
return '';
|
||||
}
|
||||
|
||||
if (substr($type, 0, 6) === 'array<' && substr($type, -1) === '>') {
|
||||
if (preg_match('/^[\w-]+<.*>$/', $type)) {
|
||||
return $type;
|
||||
}
|
||||
|
||||
|
||||
@@ -219,6 +219,10 @@ class CollectionTest extends TestCase
|
||||
'DocBlock[]|int[]',
|
||||
array($namespace.'DocBlock[]', 'int[]')
|
||||
),
|
||||
array(
|
||||
'array<string>',
|
||||
array('array<string>')
|
||||
),
|
||||
array(
|
||||
'array<int, string>',
|
||||
array('array<int, string>')
|
||||
@@ -243,6 +247,42 @@ class CollectionTest extends TestCase
|
||||
'Alias\LinkDescriptor::setLink()',
|
||||
array('\My\Space\Aliasing\LinkDescriptor::setLink()')
|
||||
),
|
||||
array(
|
||||
'int<0, 100>',
|
||||
array('int<0, 100>')
|
||||
),
|
||||
array(
|
||||
'non-empty-array<string>',
|
||||
array('non-empty-array<string>')
|
||||
),
|
||||
array(
|
||||
'non-empty-array<int, string>',
|
||||
array('non-empty-array<int, string>')
|
||||
),
|
||||
array(
|
||||
'list<string>',
|
||||
array('list<string>')
|
||||
),
|
||||
array(
|
||||
'non-empty-list<string>',
|
||||
array('non-empty-list<string>')
|
||||
),
|
||||
array(
|
||||
'key-of<MyClass::ARRAY_CONST>',
|
||||
array('key-of<MyClass::ARRAY_CONST>')
|
||||
),
|
||||
array(
|
||||
'value-of<MyClass::ARRAY_CONST>',
|
||||
array('value-of<MyClass::ARRAY_CONST>')
|
||||
),
|
||||
array(
|
||||
'value-of<MyBackedEnum>',
|
||||
array('value-of<MyBackedEnum>')
|
||||
),
|
||||
array(
|
||||
'iterable<string>',
|
||||
array('iterable<string>')
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user