mirror of
https://github.com/danog/phpdoc.git
synced 2024-11-26 12:04:47 +01:00
Fixes
This commit is contained in:
parent
0e907c3db3
commit
1c410ad894
@ -131,7 +131,7 @@ class ClassDoc extends GenericDoc
|
|||||||
$init .= "\n";
|
$init .= "\n";
|
||||||
$init .= "## Method list:\n";
|
$init .= "## Method list:\n";
|
||||||
foreach ($this->methods as $method) {
|
foreach ($this->methods as $method) {
|
||||||
$init .= "* `".$method->getSignature()."`\n";
|
$init .= "* ".$method->getSignatureLink()."\n";
|
||||||
}
|
}
|
||||||
$init .= "\n";
|
$init .= "\n";
|
||||||
$init .= "## Methods:\n";
|
$init .= "## Methods:\n";
|
||||||
|
@ -45,7 +45,15 @@ class MethodDoc extends GenericDoc
|
|||||||
|
|
||||||
parent::__construct($doc, $method instanceof ReflectionMethod ? $method->getDeclaringClass() : $method);
|
parent::__construct($doc, $method instanceof ReflectionMethod ? $method->getDeclaringClass() : $method);
|
||||||
|
|
||||||
foreach ($doc->getTags() as $tag) {
|
$docReflection = "/**\n";
|
||||||
|
foreach ($method->getParameters() as $param) {
|
||||||
|
$type = (string) ($param->getType() ?? 'mixed');
|
||||||
|
$docReflection .= " * @param $type \$".$param->getName()."\n";
|
||||||
|
}
|
||||||
|
$docReflection .= ' * @return '.($method->getReturnType() ?? 'mixed')."\n*/";
|
||||||
|
$docReflection = $this->builder->getFactory()->create($docReflection);
|
||||||
|
|
||||||
|
foreach ([...$doc->getTags(), ...$docReflection->getTags()] as $tag) {
|
||||||
if ($tag instanceof Param && !isset($this->params[$tag->getVariableName()])) {
|
if ($tag instanceof Param && !isset($this->params[$tag->getVariableName()])) {
|
||||||
$this->params[$tag->getVariableName()] = [
|
$this->params[$tag->getVariableName()] = [
|
||||||
$tag->getType(),
|
$tag->getType(),
|
||||||
@ -108,6 +116,20 @@ class MethodDoc extends GenericDoc
|
|||||||
}
|
}
|
||||||
return $sig;
|
return $sig;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Get method signature link.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getSignatureLink(): string
|
||||||
|
{
|
||||||
|
$sig = $this->getSignature();
|
||||||
|
$sigLink = strtolower($sig);
|
||||||
|
$sigLink = preg_replace('/[^\w ]+/', ' ', $sigLink);
|
||||||
|
$sigLink = preg_replace('/ +/', ' ', $sigLink);
|
||||||
|
$sigLink = str_replace(' ', '-', $sigLink);
|
||||||
|
return "[`$sig`](#$sigLink)";
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Generate markdown for method.
|
* Generate markdown for method.
|
||||||
*
|
*
|
||||||
@ -145,6 +167,7 @@ class MethodDoc extends GenericDoc
|
|||||||
}
|
}
|
||||||
$sig .= $this->seeAlso($namespace ?? $this->namespace);
|
$sig .= $this->seeAlso($namespace ?? $this->namespace);
|
||||||
$sig .= "\n";
|
$sig .= "\n";
|
||||||
|
|
||||||
return $sig;
|
return $sig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user