# wpide/3.5.9/vendor/php-di/phpdoc-reader/README.md

WPIDE – File Manager &amp; Code Editor, version 3.5.9. 58 lines.

- Page: https://pluginprobe.com/plugins/wpide/3.5.9/code/vendor/php-di/phpdoc-reader/README.md
- Raw: https://pluginprobe.com/plugins/wpide/3.5.9/raw/vendor/php-di/phpdoc-reader/README.md
- Modified: 2022-07-30T20:33:10+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wpide/3.5.9/code/vendor/php-di/phpdoc-reader/README.md#L10-L20`.

````markdown
# PhpDocReader

![](https://img.shields.io/packagist/dt/PHP-DI/phpdoc-reader.svg)

This project is used by:

- [PHP-DI 6](http://php-di.org/)
- [phockito-unit-php-di](https://github.com/balihoo/phockito-unit-php-di)

Fork the README to add your project here.

## Features

PhpDocReader parses `@var` and `@param` values in PHP docblocks:

```php

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:

- fully qualified name (starting with `\`)
- imported class name (eg. `use My\Cache\Backend;`)
- relative class name (from the current namespace, like `SubNamespace\MyClass`)
- aliased class name  (eg. `use My\Cache\Backend as FooBar;`)

Primitive types (`@var string`) are ignored (returns null), only valid class names are returned.

## Usage

```php
$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);
```

````
