15 KiB
Table of contents
- \PHPDocsMD\ClassEntity
- \PHPDocsMD\ClassEntityFactory
- \PHPDocsMD\CodeEntity
- \PHPDocsMD\DocInfo
- \PHPDocsMD\DocInfoExtractor
- \PHPDocsMD\FunctionEntity
- \PHPDocsMD\FunctionFinder
- \PHPDocsMD\MDTableGenerator
- \PHPDocsMD\ParamEntity
- \PHPDocsMD\Reflector
- \PHPDocsMD\ReflectorInterface (interface)
- \PHPDocsMD\UseInspector
- \PHPDocsMD\Utils
- \PHPDocsMD\Console\CLI
- \PHPDocsMD\Console\PHPDocsMDCommand
### Class: \PHPDocsMD\ClassEntity
Object describing a class or an interface
| Visibility | Function |
|---|---|
| public | generateAnchor() : string Generates an anchor link out of the generated title (see generateTitle) |
| public | generateTitle(string $format='%label%: %name% %extra%') : stringGenerate a title describing the class this object is referring to |
| public | getExtends() : string |
| public | getFunctions() : \PHPDocsMD\FunctionEntity[] |
| public | getInterfaces() : array |
| public | hasIgnoreTag(bool $toggle=null) : bool |
| public | isAbstract(bool $toggle=null) : bool |
| public | isInterface(bool $toggle=null) : bool |
| public | isNative(bool $toggle=null) : bool |
| public | isSame(string/object $class) : bool Check whether this object is referring to given class name or object instance |
| public | setExtends(string $extends) : void |
| public | setFunctions(\PHPDocsMD\FunctionEntity[] $functions) : void |
| public | setInterfaces(array $implements) : void |
| public | setName(string $name) : void |
This class extends \PHPDocsMD\CodeEntity
### Class: \PHPDocsMD\ClassEntityFactory
Class capable of creating ClassEntity objects
| Visibility | Function |
|---|---|
| public | __construct(\PHPDocsMD\DocInfoExtractor $docInfoExtractor) : void |
| public | create(\ReflectionClass $reflection) : mixed |
### Class: \PHPDocsMD\CodeEntity
Object describing a piece of code
| Visibility | Function |
|---|---|
| public | getDeprecationMessage() : string |
| public | getDescription() : string |
| public | getExample() : string |
| public | getName() : string |
| public | isDeprecated(bool $toggle=null) : void/bool |
| public | setDeprecationMessage(string $deprecationMessage) : void |
| public | setDescription(string $description) : void |
| public | setExample(string $example) : void |
| public | setName(string $name) : void |
### Class: \PHPDocsMD\DocInfo
Class containing information about a function/class that's being made available via a comment block
| Visibility | Function |
|---|---|
| public | __construct(array $data) : void |
| public | getDeprecationMessage() : string |
| public | getDescription() : string |
| public | getExample() : string |
| public | getParameterInfo(string $name) : array |
| public | getParameters() : array |
| public | getReturnType() : string |
| public | shouldBeIgnored() : bool |
| public | shouldInheritDoc() : bool |
### Class: \PHPDocsMD\DocInfoExtractor
Class that can extract information from a function/class comment
| Visibility | Function |
|---|---|
| public | applyInfoToEntity(\ReflectionClass/\ReflectionMethod $reflection, \PHPDocsMD\DocInfo $docInfo, \PHPDocsMD\CodeEntity $code) : void |
| public | extractInfo(\ReflectionClass/\ReflectionMethod $reflection) : \PHPDocsMD\DocInfo |
### Class: \PHPDocsMD\FunctionEntity
Object describing a function
| Visibility | Function |
|---|---|
| public | getClass() : string |
| public | getParams() : \PHPDocsMD\ParamEntity[] |
| public | getReturnType() : string |
| public | getVisibility() : string |
| public | hasParams() : bool |
| public | isAbstract(bool $toggle=null) : bool |
| public | isReturningNativeClass(bool $toggle=null) : bool |
| public | isStatic(bool $toggle=null) : bool |
| public | setClass(string $class) : void |
| public | setParams(\PHPDocsMD\ParamEntity[] $params) : void |
| public | setReturnType(string $returnType) : void |
| public | setVisibility(string $visibility) : void |
This class extends \PHPDocsMD\CodeEntity
### Class: \PHPDocsMD\FunctionFinder
Find a specific function in a class or an array of classes
| Visibility | Function |
|---|---|
| public | find(string $methodName, string $className) : bool/\PHPDocsMD\FunctionEntity |
| public | findInClasses(string $methodName, array $classes) : bool/\PHPDocsMD\FunctionEntity |
### Class: \PHPDocsMD\MDTableGenerator
Class that can create a markdown-formatted table describing class functions referred to via FunctionEntity objects
Example
<?php
$generator = new PHPDocsMD\MDTableGenerator();
$generator->openTable();
foreach($classEntity->getFunctions() as $func) {
$generator->addFunc( $func );
}
echo $generator->getTable();
| Visibility | Function |
|---|---|
| public | addFunc(\PHPDocsMD\FunctionEntity $func) : string Generates a markdown formatted table row with information about given function. Then adds the row to the table and returns the markdown formatted string. |
| public | appendExamplesToEndOfTable(bool $toggle) : void All example comments found while generating the table will be appended to the end of the table. Set $toggle to false to prevent this behaviour |
| public | doDeclareAbstraction(bool $toggle) : void Toggle whether or not methods being abstract (or part of an interface) should be declared as abstract in the table |
| public static | formatExampleComment(string $example) : string Create a markdown-formatted code view out of an example comment |
| public | getTable() : string |
| public | openTable() : void Begin generating a new markdown-formatted table |
### Class: \PHPDocsMD\ParamEntity
Object describing a function parameter
| Visibility | Function |
|---|---|
| public | getDefault() : boolean |
| public | getNativeClassType() : string/null |
| public | getType() : string |
| public | setDefault(boolean $default) : void |
| public | setType(string $type) : void |
This class extends \PHPDocsMD\CodeEntity
### Class: \PHPDocsMD\Reflector
Class that can compute ClassEntity objects out of real classes
| Visibility | Function |
|---|---|
| public | __construct(string $className, \PHPDocsMD\FunctionFinder $functionFinder=null, \PHPDocsMD\DocInfoExtractor $docInfoExtractor=null, \PHPDocsMD\UseInspector $useInspector=null, \PHPDocsMD\ClassEntityFactory $classEntityFactory=null) : void |
| public | getClassEntity() : \PHPDocsMD\ClassEntity |
| public static | getParamType(\ReflectionParameter $refParam) : string Tries to find out if the type of the given parameter. Will return empty string if not possible. |
| protected | createFunctionEntity(\ReflectionMethod $method, \PHPDocsMD\ClassEntity $class, array $useStatements) : bool/\PHPDocsMD\FunctionEntity |
| protected | shouldIgnoreFunction(\PHPDocsMD\DocInfo $info, \ReflectionMethod $method, \PHPDocsMD\ClassEntity $class) : bool |
Examples of Reflector::getParamType()
<?php
$reflector = new \\ReflectionClass('MyClass');
foreach($reflector->getMethods() as $method ) {
foreach($method->getParameters() as $param) {
$name = $param->getName();
$type = Reflector::getParamType($param);
printf("%s = %s\n", $name, $type);
}
}
This class implements \PHPDocsMD\ReflectorInterface
### Interface: \PHPDocsMD\ReflectorInterface
Interface for classes that can compute ClassEntity objects
| Visibility | Function |
|---|---|
| public | getClassEntity() : \PHPDocsMD\ClassEntity |
### Class: \PHPDocsMD\UseInspector
Class that can extract all use statements in a file
| Visibility | Function |
|---|---|
| public | getUseStatements(\ReflectionClass $reflectionClass) : array |
| public | getUseStatementsInFile(string $filePath) : array |
| public | getUseStatementsInString(string $content) : string[] |
### Class: \PHPDocsMD\Utils
| Visibility | Function |
|---|---|
| public static | getClassBaseName(string $fullClassName) : string |
| public static | isClassReference(string $typeDeclaration) : bool |
| public static | isNativeClassReference(mixed $typeDeclaration) : bool |
| public static | sanitizeClassName(string $name) : string |
| public static | sanitizeDeclaration(string $typeDeclaration, string $currentNameSpace, string $delimiter=`' |
### Class: \PHPDocsMD\Console\CLI
Command line interface used to extract markdown-formatted documentation from classes
| Visibility | Function |
|---|---|
| public | __construct() : void |
| public | run(\Symfony\Component\Console\Input\InputInterface $input=null, \Symfony\Component\Console\Output\OutputInterface $output=null) : int |
This class extends \Symfony\Component\Console\Application
### Class: \PHPDocsMD\Console\PHPDocsMDCommand
Console command used to extract markdown-formatted documentation from classes
| Visibility | Function |
|---|---|
| public | extractClassNameFromLine(string $type, string $line) : string |
| protected | configure() : void |
| protected | execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) : int/null |
This class extends \Symfony\Component\Console\Command\Command