2 namespace Consolidation\AnnotatedCommand\Parser\Internal;
5 * Hold some state. Collect tags.
9 /** @var DocblockTag|null Current tag */
12 /** @var DocblockTag[] All tag */
16 * DocblockTag constructor
18 public function __construct()
20 $this->current = null;
24 public function parseLine($line)
26 if (DocblockTag::isTag($line)) {
27 return $this->createTag($line);
30 return $this->storeCurrentTag();
32 return $this->accumulateContent($line);
35 public function getTags()
37 $this->storeCurrentTag();
41 protected function createTag($line)
43 DocblockTag::splitTagAndContent($line, $matches);
44 $this->storeCurrentTag();
45 $this->current = new DocblockTag($matches['tag'], $matches['description']);
49 protected function storeCurrentTag()
51 if (!$this->current) {
54 $this->tags[] = $this->current;
55 $this->current = false;
59 protected function accumulateContent($line)
61 if (!$this->current) {
64 $this->current->appendContent($line);