Skip to content

5. Plugins

Marco Muths edited this page Mar 25, 2017 · 8 revisions

Write your own Namespace Filter

Just implement PhpDA\Parser\Filter\NamespaceFilterInterface to your filter class to modify the namespace of collected dependencies.

After that you can add it to the configuration. For autoloading add your plugin to classMap configuration.

Write your own Reference Validator

Just implement PhpDA\Reference\ValidatorInterface to your reference validator class to verify each dependency.

After that you can add it to the configuration. For autoloading add your plugin to classMap configuration.

Write your own Visitors

Visitors are provided by Visitor-Pattern implemented by Nikic's Php-Parser. Read the docs to get into the idea of visitor.

To get your own visitor, just create a new one by extending PhpDA\Parser\Visitor\AbstractVisitor. Beside this you have to implement one of the following Interfaces to declare the concern by contract:

  • PhpDA\Parser\Visitor\Feature\UsedNamespaceCollectorInterface
  • PhpDA\Parser\Visitor\Feature\UnsupportedNamespaceCollectorInterface
  • PhpDA\Parser\Visitor\Feature\NamespacedStringCollectorInterface

After that you can add it to the configuration. For autoloading add your plugin to classMap configuration.

Write your own Formatters

To get your own Formatter to create other reports, just implement PhpDA\Writer\Strategy\StrategyInterface to a new one.

After that you can add it to the configuration. For autoloading add your plugin to classMap configuration.