Skip to content

Commit 67be503

Browse files
committed
只重置property和method注释
1 parent 441d24f commit 67be503

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

src/ModelGenerator.php

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -343,35 +343,34 @@ protected function createPhpDocs()
343343
$properties = [];
344344
$methods = [];
345345
$tags = [];
346-
if (!$this->reset) {
347-
try {
348-
//读取文件注释
349-
$phpdoc = DocBlockFactory::createInstance()->create($this->reflection, $context);
350-
351-
$summary = $phpdoc->getSummary();
352-
$properties = [];
353-
$methods = [];
354-
$tags = $phpdoc->getTags();
355-
foreach ($tags as $key => $tag) {
356-
if ($tag instanceof DocBlock\Tags\Property || $tag instanceof DocBlock\Tags\PropertyRead || $tag instanceof DocBlock\Tags\PropertyWrite) {
357-
if ($this->overwrite && array_key_exists($tag->getVariableName(), $this->properties)) {
358-
//覆盖原来的
359-
unset($tags[$key]);
360-
} else {
361-
$properties[] = $tag->getVariableName();
362-
}
363-
} elseif ($tag instanceof DocBlock\Tags\Method) {
364-
if ($this->overwrite && array_key_exists($tag->getMethodName(), $this->methods)) {
365-
//覆盖原来的
366-
unset($tags[$key]);
367-
} else {
368-
$methods[] = $tag->getMethodName();
369-
}
346+
347+
try {
348+
//读取文件注释
349+
$phpdoc = DocBlockFactory::createInstance()->create($this->reflection, $context);
350+
351+
$summary = $phpdoc->getSummary();
352+
$properties = [];
353+
$methods = [];
354+
$tags = $phpdoc->getTags();
355+
foreach ($tags as $key => $tag) {
356+
if ($tag instanceof DocBlock\Tags\Property || $tag instanceof DocBlock\Tags\PropertyRead || $tag instanceof DocBlock\Tags\PropertyWrite) {
357+
if (($this->overwrite && array_key_exists($tag->getVariableName(), $this->properties)) || $this->reset) {
358+
//覆盖原来的
359+
unset($tags[$key]);
360+
} else {
361+
$properties[] = $tag->getVariableName();
362+
}
363+
} elseif ($tag instanceof DocBlock\Tags\Method) {
364+
if (($this->overwrite && array_key_exists($tag->getMethodName(), $this->methods)) || $this->reset) {
365+
//覆盖原来的
366+
unset($tags[$key]);
367+
} else {
368+
$methods[] = $tag->getMethodName();
370369
}
371370
}
372-
} catch (InvalidArgumentException $e) {
373-
374371
}
372+
} catch (InvalidArgumentException $e) {
373+
375374
}
376375

377376
$fqsenResolver = new FqsenResolver();

0 commit comments

Comments
 (0)