1
0
mirror of https://github.com/danog/phpdoc.git synced 2024-11-26 20:14:51 +01:00
This commit is contained in:
Daniil Gentili 2023-07-14 16:38:29 +02:00
parent 12d8733995
commit 1ac05c37d8
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
3 changed files with 6 additions and 25 deletions

View File

@ -39,12 +39,7 @@ class ClassDoc extends GenericDoc
{ {
$this->builder = $builder; $this->builder = $builder;
$this->name = $reflectionClass->getName(); $this->name = $reflectionClass->getName();
$doc = $reflectionClass->getDocComment(); $doc = $reflectionClass->getDocComment() ?: '/** */';
if (!$doc) {
\fprintf(STDERR, $reflectionClass->getName()." has no PHPDOC".PHP_EOL);
$this->ignore = true;
return;
}
$doc = $this->builder->getFactory()->create($doc); $doc = $this->builder->getFactory()->create($doc);
parent::__construct($doc, $reflectionClass); parent::__construct($doc, $reflectionClass);

View File

@ -22,14 +22,6 @@ class FunctionDoc extends MethodDoc
{ {
$this->builder = $builder; $this->builder = $builder;
$this->name = $reflectionClass->getName(); $this->name = $reflectionClass->getName();
$doc = $reflectionClass->getDocComment();
if (!$doc) {
\fprintf(STDERR, $reflectionClass->getName()." has no PHPDOC".PHP_EOL);
$this->ignore = true;
return;
}
$doc = $this->builder->getFactory()->create($doc);
parent::__construct($builder, $reflectionClass); parent::__construct($builder, $reflectionClass);
} }
/** /**

View File

@ -31,16 +31,7 @@ class MethodDoc extends GenericDoc
{ {
$this->builder = $phpDocBuilder; $this->builder = $phpDocBuilder;
$this->name = $method->getName(); $this->name = $method->getName();
$doc = $method->getDocComment(); $doc = $method->getDocComment() ?: '/** */';
if (!$doc) {
$this->ignore = true;
if ($method instanceof ReflectionMethod) {
\fprintf(STDERR, $method->getDeclaringClass()->getName().'::'.$method->getName().' has no PHPDOC!'.PHP_EOL);
} else {
\fprintf(STDERR, $method->getName()." has no PHPDOC!".PHP_EOL);
}
return;
}
$doc = $this->builder->getFactory()->create($doc); $doc = $this->builder->getFactory()->create($doc);
parent::__construct($doc, $method instanceof ReflectionMethod ? $method->getDeclaringClass() : $method); parent::__construct($doc, $method instanceof ReflectionMethod ? $method->getDeclaringClass() : $method);
@ -84,7 +75,10 @@ class MethodDoc extends GenericDoc
} elseif ($tag instanceof Generic && $tag->getName() === 'psalm-return') { } elseif ($tag instanceof Generic && $tag->getName() === 'psalm-return') {
$this->psalmReturn = $tag; $this->psalmReturn = $tag;
} elseif ($tag instanceof Generic && $tag->getName() === 'psalm-param') { } elseif ($tag instanceof Generic && $tag->getName() === 'psalm-param') {
[$type, $description] = \explode(" $", $tag->getDescription(), 2); $desc = $tag->getDescription();
$dollar = \strrpos($desc, '$');
$type = \substr($tag, 0, $dollar-1);
$description = \substr($tag, $dollar+1);
$description .= ' '; $description .= ' ';
[$varName, $description] = \explode(" ", $description, 2); [$varName, $description] = \explode(" ", $description, 2);
if (!$description && isset($params[$varName])) { if (!$description && isset($params[$varName])) {