Skip to content

Commit

Permalink
只重置property和method注释
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwuxin committed Mar 10, 2020
1 parent 441d24f commit 67be503
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions src/ModelGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,35 +343,34 @@ protected function createPhpDocs()
$properties = [];
$methods = [];
$tags = [];
if (!$this->reset) {
try {
//读取文件注释
$phpdoc = DocBlockFactory::createInstance()->create($this->reflection, $context);

$summary = $phpdoc->getSummary();
$properties = [];
$methods = [];
$tags = $phpdoc->getTags();
foreach ($tags as $key => $tag) {
if ($tag instanceof DocBlock\Tags\Property || $tag instanceof DocBlock\Tags\PropertyRead || $tag instanceof DocBlock\Tags\PropertyWrite) {
if ($this->overwrite && array_key_exists($tag->getVariableName(), $this->properties)) {
//覆盖原来的
unset($tags[$key]);
} else {
$properties[] = $tag->getVariableName();
}
} elseif ($tag instanceof DocBlock\Tags\Method) {
if ($this->overwrite && array_key_exists($tag->getMethodName(), $this->methods)) {
//覆盖原来的
unset($tags[$key]);
} else {
$methods[] = $tag->getMethodName();
}

try {
//读取文件注释
$phpdoc = DocBlockFactory::createInstance()->create($this->reflection, $context);

$summary = $phpdoc->getSummary();
$properties = [];
$methods = [];
$tags = $phpdoc->getTags();
foreach ($tags as $key => $tag) {
if ($tag instanceof DocBlock\Tags\Property || $tag instanceof DocBlock\Tags\PropertyRead || $tag instanceof DocBlock\Tags\PropertyWrite) {
if (($this->overwrite && array_key_exists($tag->getVariableName(), $this->properties)) || $this->reset) {
//覆盖原来的
unset($tags[$key]);
} else {
$properties[] = $tag->getVariableName();
}
} elseif ($tag instanceof DocBlock\Tags\Method) {
if (($this->overwrite && array_key_exists($tag->getMethodName(), $this->methods)) || $this->reset) {
//覆盖原来的
unset($tags[$key]);
} else {
$methods[] = $tag->getMethodName();
}
}
} catch (InvalidArgumentException $e) {

}
} catch (InvalidArgumentException $e) {

}

$fqsenResolver = new FqsenResolver();
Expand Down

0 comments on commit 67be503

Please sign in to comment.