Handle more PHPDoc type keyworks (#23)

* Added advanced PHPDoc type keyworks

* Fixed typed keywords
This commit is contained in:
Nereo Berardozzi
2024-12-24 19:06:02 +01:00
committed by GitHub
parent d5d2d76892
commit e5c8b970d6
2 changed files with 49 additions and 2 deletions
@@ -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;
}