DocTracer PHP ReflectionClass and API Documentation Generator

Namespace
Class
Constant | Property | Method
Documentation
namespace Mdz
namespace Mdz
class DocTracer

Analyze PHP class and docBlock to generate API Documentation.

DocTracer helps you to create meaningful API documentation reports. Reflecting PHP class information and show markdown formatted documentation on one page.

How to use:

$tracer = new \Mdz\DocTracer($baseDir);
$tracer->inspect($targetDir);
echo $tracer->render();
@author

@author Mudzakkir me@mdzstack.com

@license

@license https://opensource.org/licenses/MIT

public const VERSION = '1.0.2';
@varstring
protected $baseDir = '';

Base directory path.

@varstring
protected $data = [];

Holds all reports data.

@vararray
public __construct ( string $baseDir = './', )
@paramstring$baseDir
public inspect ( string $targetDir, array $exclude = [], ): Mdz\DocTracer

Find, check and parse all PHP files.

PHP ReflectionClass require autoloader or class must exist.

@paramstring$targetDir

Directory to check

@paramarray$exclude

Exclude directory

@return\Mdz​\DocTracer
public getResults ( ): array

Return reports information.

@returnarray
protected phpFinder ( string $path, array $exclude = [], ): Iterator

Find PHP files inside directory recursively.

@paramstring$path
@paramarray$exclude
@return\Iterator

of \SplFileInfo

protected parseNamespace ( string $content, ): string

Get fully qualified namespace from content.

@paramstring$content
@returnstring

Fully qualified namespace

protected getConstants ( ReflectionClass $refClass, string $fqnClass, ): array

Get class constants information.

@param\ReflectionClass$refClass
@paramstring$fqnClass
@returnarray
protected getProperties ( ReflectionClass $refClass, string $fqnClass, ): array

Get class properties information.

@param\ReflectionClass$refClass
@paramstring$fqnClass
@returnarray
protected getMethods ( ReflectionClass $refClass, string $fqnClass, ): array

Get class methods information.

@param\ReflectionClass$refClass
@paramstring$fqnClass
@returnarray
protected getMethodParams ( ReflectionMethod $refMethod, ): array

Get method parameters information.

@param\ReflectionMethod$refMethod
@returnarray
protected getTypeHint ( ReflectionType $refType, ): string

Get the type hint

@param\ReflectionType$refType
@returnstring
protected getValueType ( $value, )

Check the type of reflection $value to printable value.

Word "n/a" to differentiate between the assigned default value "null" and the null returned by reflection when a default value is not assigned.

@parammixed​|null$value
@returnstring​|int
protected parseDocBlock ( Reflector $ref, ): array

Get DocBLock informations.

@param\Reflector$ref

Has the getDocComment() method

@returnarray
public render ( array $params = [], ): string

Render in HTML page.

Available setting:

  • title Page heading (h1) and meta title
  • tagline Page heading tagline
  • footer Footer information. Default: {title} - {tagline}
  • theme Report theme. Options: default, darkmoon
  • css Customize the report style
  • template Custom template path
@paramarray$setting
@returnstring
protected formatDocBlock ( array $docBlock, ): string

Standarize the documentation HTML format.

The class, constant, property and method share the same HTML output.

@paramarray$docBlock
@returnstring
protected markdown ( string $content, ): string

Pretify documentation with Markdown.

@paramstring$content
@returnstring
protected wordBreak ( string $content, ): string

Break part namespace and types with ​ zero-width space.

@paramstring$content
@returnstring
^Top