Skip to content

3. Configuration

Marco Muths edited this page Feb 3, 2015 · 6 revisions

This tool is configurable by a YAML file.

mode: 'usage' # usage | call | inheritance
source: './src'
filePattern: '*.php'
ignore: 'tests'
formatter: 'PhpDA\Writer\Strategy\Svg'
target: './phpda.svg'
referenceValidator: 'Full\Qualified\Namespace\To\ReferenceValidator'
groupLength: 1
visitor:
  - PhpDA\Parser\Visitor\TagCollector
  - PhpDA\Parser\Visitor\SuperglobalCollector
  - PhpDA\Parser\Visitor\UnsupportedEvalCollector
  - PhpDA\Parser\Visitor\UnsupportedFuncCollector
  - PhpDA\Parser\Visitor\UnsupportedVarCollector
  - PhpDA\Parser\Visitor\UnsupportedGlobalCollector
  - PhpDA\Parser\Visitor\NamespacedStringCollector
  - PhpDA\Parser\Visitor\IocContainerAccessorCollector
visitorOptions:
  PhpDA\Parser\Visitor\Required\DeclaredNamespaceCollector: {minDepth: 2, sliceLength: 2}
  PhpDA\Parser\Visitor\Required\MetaNamespaceCollector: {minDepth: 2, sliceLength: 1}
  PhpDA\Parser\Visitor\Required\UsedNamespaceCollector: {minDepth: 2, sliceLength: 1}
  PhpDA\Parser\Visitor\TagCollector: {minDepth: 2, sliceLength: 1}

Available Options

Name Type Description
mode string Graph mode: usage-Graph (default), call-Graph or inheritance-Graph
source string To be analyzed directory
filePattern string Pattern to match files inside source to be analyzed
ignore string, array Optional: Excluding directories inside source
formatter string Output Formatter; must be declared with a FQCN
target string File path to write output
referenceValidator string Optional: Reference Validator; must be declared with a FQCN
groupLength integer Optional: Group found namespaces by count of their namespaceparts
visitor array Optional: Indexed list of visitors to use; each visitor must be declared with a FQCN
visitorOptions array Optional: Associative list modelled by Visitor-FQCN => Properties

referenceValidator

Perform a detection of violations between layers in a tiered architecture according to compliance with SoC (Separation of Concerns), LoD (Law of Demeter).

Create a custom validator which verifies that each dependency is meeting your defined architecture definition.

Write your own Reference Validator

Available visitors

FQCN Description
PhpDA\Parser\Visitor\TagCollector Collects found namespaces in DocBlocks to declare it as a dependency
PhpDA\Parser\Visitor\SuperglobalCollector Collects PHP-Superglobals to declare it as a dependency
PhpDA\Parser\Visitor\UnsupportedEvalCollector Collects eval expressions to log it as Unsupported
PhpDA\Parser\Visitor\UnsupportedFuncCollector Collects dynamic function handler, such as create_function to log it as Unsupported
PhpDA\Parser\Visitor\UnsupportedVarCollector Collects dynamic variable declarations, such as $$x to log it as Unsupported
PhpDA\Parser\Visitor\UnsupportedGlobalCollector Collects global $foo expressions to log it as Unsupported
PhpDA\Parser\Visitor\NamespacedStringCollector Collects strings which looks like a namespace to log it as NamespacedString
PhpDA\Parser\Visitor\IocContainerAccessorCollector Collects accessor methods which looks like a object retrieval to log it as NamespacedString

Available visitorOptions

Each visitor is configurable by setting visitorOptions.

Property Type Description
excludePattern string Ignore namespaces where pattern is matched. Default is null, which means that filter is disabled
minDepth integer Ignore namespaces where count of namespace parts is less than defined. Default is 0, which means that filter is disabled
sliceOffset integer Filter namespaces with array_slice on their parts. Default is null, which means that filter is disabled
sliceLength integer Filter namespaces with array_slice on their parts. Default is null, which means that filter is disabled

Required Visitors

These built-in visitors are not optional but also configurable by visitorOptions.

FQCN Description
PhpDA\Parser\Visitor\Required\DeclaredNamespaceCollector Collects class names
PhpDA\Parser\Visitor\Required\MetaNamespaceCollector Collects names of base classes, traits and implementations
PhpDA\Parser\Visitor\Required\UsedNamespaceCollector Collects used class names

Available formatter

FQCN Description
PhpDA\Writer\Strategy\Svg Outputs to scalable vector graphic (SVG)
PhpDA\Writer\Strategy\Script Outputs to a plain graph description language (DOT)
PhpDA\Writer\Strategy\Html Outputs to a HTML file
PhpDA\Writer\Strategy\Json Outputs to a JSON representation
Clone this wiki locally