|
1
|
|
|
<?php |
|
2
|
|
|
namespace Consolidation\AnnotatedCommand\Parser\Internal; |
|
3
|
|
|
|
|
4
|
|
|
use phpDocumentor\Reflection\DocBlock; |
|
5
|
|
|
use phpDocumentor\Reflection\DocBlock\Tag\ParamTag; |
|
6
|
|
|
use phpDocumentor\Reflection\DocBlock\Tag\ReturnTag; |
|
7
|
|
|
use Consolidation\AnnotatedCommand\Parser\CommandInfo; |
|
8
|
|
|
use Consolidation\AnnotatedCommand\Parser\DefaultsWithDescriptions; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Given a class and method name, parse the annotations in the |
|
12
|
|
|
* DocBlock comment, and provide accessor methods for all of |
|
13
|
|
|
* the elements that are needed to create an annotated Command. |
|
14
|
|
|
*/ |
|
15
|
|
|
class CommandDocBlockParser2 extends AbstractCommandDocBlockParser |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* Parse the docBlock comment for this command, and set the |
|
19
|
|
|
* fields of this class with the data thereby obtained. |
|
20
|
|
|
*/ |
|
21
|
|
|
public function parse() |
|
22
|
|
|
{ |
|
23
|
|
|
$docblockComment = $this->reflection->getDocComment(); |
|
24
|
|
|
$phpdoc = new DocBlock($docblockComment); |
|
25
|
|
|
|
|
26
|
|
|
// First set the description (synopsis) and help. |
|
27
|
|
|
$this->commandInfo->setDescription((string)$phpdoc->getShortDescription()); |
|
|
|
|
|
|
28
|
|
|
$this->commandInfo->setHelp((string)$phpdoc->getLongDescription()); |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
$this->processAllTags($phpdoc); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
protected function getTagContents($tag) |
|
34
|
|
|
{ |
|
35
|
|
|
return $tag->getContent(); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Store the data from a @arg annotation in our argument descriptions. |
|
40
|
|
|
*/ |
|
41
|
|
|
protected function processArgumentTag($tag) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->addOptionOrArgumentTag($tag, $this->commandInfo->arguments()); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Store the data from a @param annotation in our argument descriptions. |
|
48
|
|
|
*/ |
|
49
|
|
|
protected function processParamTag($tag) |
|
50
|
|
|
{ |
|
51
|
|
|
if (!$tag instanceof ParamTag) { |
|
|
|
|
|
|
52
|
|
|
return; |
|
53
|
|
|
} |
|
54
|
|
|
return parent::processParamTag($tag); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Store the data from a @return annotation in our argument descriptions. |
|
59
|
|
|
*/ |
|
60
|
|
|
protected function processReturnTag($tag) |
|
61
|
|
|
{ |
|
62
|
|
|
if (!$tag instanceof ReturnTag) { |
|
|
|
|
|
|
63
|
|
|
return; |
|
64
|
|
|
} |
|
65
|
|
|
$this->commandInfo->setReturnType($tag->getType()); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.