Documentor
Documentor
Generates API documentation by parsing PHP source files.
class DocumentorScans a source tree, builds an index of discovered namespaces and symbols, then renders documentation output using Smarty templates in markdown or index formats.
Constants
DOC_OUTPUT_HTML
public const DOC_OUTPUT_HTML = 1DOC_OUTPUT_MARKDOWN
public const DOC_OUTPUT_MARKDOWN = 2DOC_OUTPUT_INDEX
public const DOC_OUTPUT_INDEX = 3array
private const array = nullProperties
outputFormat
Selected documentation output format.
private int $outputFormatType: int
title
public string $titleType: string
callback
public \Closure $callbackType: Closure
index
public \stdClass $indexType: stdClass
outputPath
Destination directory or file path for rendered output.
private string $outputPathType: string
scanPath
Source file or directory path to scan for PHP symbols.
private string $scanPathType: string
fileErrors
List of files that encountered errors during parsing.
private array $fileErrorsType: array
Methods
__construct
Creates a documentation generator instance.
public __construct(int $outputFormat, ?string $title): voidParameters
| Parameter | Type | Description |
|---|---|---|
$outputFormat | int | output mode constant |
$title | string | optional documentation title |
setCallback
Sets a callback for progress and status log messages.
public setCallback(\Closure $callback): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$callback | Closure | callback that receives log text |
setScanPath
Sets the source path to scan.
public setScanPath(string $scanPath): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$scanPath | string | source file or directory |
setOutputPath
Sets the output destination path.
public setOutputPath(string $outputPath): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$outputPath | string | directory or file target for rendered docs |
getOutputPath
Gets the configured output destination path.
public getOutputPath(): stringReturns: string
generate
Scans source files and renders API documentation output.
public generate(): boolReturns: bool
generateIndex
public generateIndex(string $style = 'vuepress'): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$style | string |
scan
private scan(): boolReturns: bool
render
private render(\stdClass $index, string $outputPath): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$index | stdClass | |
$outputPath | string |
renderNamespace
private renderNamespace(ParserNamespace|\stdClass $namespace, array $subdirs, array $template): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$namespace | Hazaar\Parser\PHP\ParserNamespace | stdClass |
$subdirs | array | |
$template | array |
loadTemplates
private loadTemplates(string $path, int $outputFormat = 2): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$outputFormat | int |
updateIndex
private updateIndex(\stdClass $index, ParserFile $parsedFile): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$index | stdClass | |
$parsedFile | Hazaar\Parser\PHP\ParserFile |
pushIndexItem
private pushIndexItem(array $array, array $items): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$array | array | |
$items | array |
getFiles
private getFiles(string $path): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
postProcessRemoveEmptyLines
private postProcessRemoveEmptyLines(string $content): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$content | string |
linkifyTypes
Populates the *Link fields (ParserProperty::$typeLink,
private linkifyTypes(\stdClass $index): voidReturns: void
ParserParameter::$typeLink, ParserClass::$extendsLink/ $implementsLink) across the whole scanned index, resolving each type/extends/implements name relative to the class it was declared on and wrapping resolvable class-like names as [FQCN](https://www.php.net/manual/en/class.fqcn.php) class-link markers for Hazaar\Console\API\Documentor::postProcessReplaceClassLinks to pick up. Also resolves {@see} PHPDoc tags in every brief/detail/parameter description into the same marker syntax, in place, on the underlying DocBlock.
Must run after Hazaar\Console\API\Documentor::scan populates $this->index, and before templates render, since the templates read these *Link fields (and the rewritten brief/detail text) directly.
Parameters
| Parameter | Type | Description |
|---|---|---|
$index | stdClass |
linkifyClass
private linkifyClass(ParserClass $class): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$class | Hazaar\Parser\PHP\ParserClass |
linkifyDocBlock
Resolves {@see} tags in a DocBlock's brief/detail text in place.
private linkifyDocBlock(?DocBlock $docBlock, ParserFile $file, ?ParserNamespace $namespace, string $selfFqcn): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$docBlock | Hazaar\Parser\DocBlock | |
$file | Hazaar\Parser\PHP\ParserFile | |
$namespace | Hazaar\Parser\PHP\ParserNamespace | |
$selfFqcn | string |
linkifySeeTags
Resolves inline Hazaar\Console\API\X PHPDoc tags into [FQCN](https://www.php.net/manual/en/class.fqcn.php) (or, for a
private linkifySeeTags(?string $text, ParserFile $file, ?ParserNamespace $namespace, string $selfFqcn): ?stringReturns: string
Class::$prop/Class::method() member reference, [FQCN](https://www.php.net/manual/en/class.fqcn.php)) class-link markers for Hazaar\Console\API\Documentor::postProcessReplaceClassLinks to pick up. self:: resolves to $selfFqcn, the class the tag was written on.
Parameters
| Parameter | Type | Description |
|---|---|---|
$text | string | |
$file | Hazaar\Parser\PHP\ParserFile | |
$namespace | Hazaar\Parser\PHP\ParserNamespace | |
$selfFqcn | string |
linkifyType
Resolves a (possibly union/intersection) type string to markdown,
private linkifyType(?string $type, ParserFile $file, ?ParserNamespace $namespace): ?stringReturns: string
wrapping each resolvable class/interface/trait/enum segment as a [FQCN](https://www.php.net/manual/en/class.fqcn.php) class-link marker while leaving scalar/builtin/pseudo types and the |/& separators themselves as plain text.
Parameters
| Parameter | Type | Description |
|---|---|---|
$type | string | |
$file | Hazaar\Parser\PHP\ParserFile | |
$namespace | Hazaar\Parser\PHP\ParserNamespace |
postProcessReplaceClassLinks
private postProcessReplaceClassLinks(string $content): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$content | string |
log
private log(string $message): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$message | string |
createNamespaceHierarchy
private createNamespaceHierarchy(\stdClass $item): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$item | stdClass |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:18 +0000