havocera 17d3d24b6d 提交vendor | il y a 1 an | |
---|---|---|
.. | ||
.github | il y a 1 an | |
src | il y a 1 an | |
.gitattributes | il y a 1 an | |
.gitignore | il y a 1 an | |
.phpcs.xml.dist | il y a 1 an | |
LICENSE | il y a 1 an | |
README.md | il y a 1 an | |
composer.json | il y a 1 an |
This project is used by:
Fork the README to add your project here.
PhpDocReader parses @var
and @param
values in PHP docblocks:
use My\Cache\Backend;
class Cache
{
/**
* @var Backend
*/
protected $backend;
/**
* @param Backend $backend
*/
public function __construct($backend)
{
}
}
It supports namespaced class names with the same resolution rules as PHP:
\
)use My\Cache\Backend;
)SubNamespace\MyClass
)use My\Cache\Backend as FooBar;
)Primitive types (@var string
) are ignored (returns null), only valid class names are returned.
$reader = new PhpDocReader();
// Read a property type (@var phpdoc)
$property = new ReflectionProperty($className, $propertyName);
$propertyClass = $reader->getPropertyClass($property);
// Read a parameter type (@param phpdoc)
$parameter = new ReflectionParameter(array($className, $methodName), $parameterName);
$parameterClass = $reader->getParameterClass($parameter);