1 | <?php |
||
13 | class DocblockTag |
||
14 | { |
||
15 | /** @var string Name of the tag */ |
||
16 | protected $tag; |
||
17 | |||
18 | /** @var string|null Contents of the tag. */ |
||
19 | protected $content; |
||
20 | |||
21 | const TAG_REGEX = '@(?P<tag>[^ \t]+)[ \t]*'; |
||
22 | const VARIABLE_REGEX = '\\$(?P<variable>[^ \t]+)[ \t]*'; |
||
23 | const VARIABLE_OR_WORD_REGEX = '\\$?(?P<variable>[^ \t]+)[ \t]*'; |
||
24 | const TYPE_REGEX = '(?P<type>[^ \t]+)[ \t]*'; |
||
25 | const WORD_REGEX = '(?P<word>[^ \t]+)[ \t]*'; |
||
26 | const DESCRIPTION_REGEX = '(?P<description>.*)'; |
||
27 | const IS_TAG_REGEX = '/^[* \t]*@/'; |
||
28 | |||
29 | /** |
||
30 | * Check if the provided string begins with a tag |
||
31 | * @param string $subject |
||
32 | * @return bool |
||
33 | */ |
||
34 | public static function isTag($subject) |
||
38 | |||
39 | /** |
||
40 | * Use a regular expression to separate the tag from the content. |
||
41 | * |
||
42 | * @param string $subject |
||
43 | * @param string[] &$matches Sets $matches['tag'] and $matches['description'] |
||
44 | * @return bool |
||
45 | */ |
||
46 | public static function splitTagAndContent($subject, &$matches) |
||
51 | |||
52 | /** |
||
53 | * DockblockTag constructor |
||
54 | */ |
||
55 | public function __construct($tag, $content = null) |
||
60 | |||
61 | /** |
||
62 | * Add more content onto a tag during parsing. |
||
63 | */ |
||
64 | public function appendContent($line) |
||
68 | |||
69 | /** |
||
70 | * Return the tag - e.g. "@foo description" returns 'foo' |
||
71 | * |
||
72 | * @return string |
||
73 | */ |
||
74 | public function getTag() |
||
78 | |||
79 | /** |
||
80 | * Return the content portion of the tag - e.g. "@foo bar baz boz" returns |
||
81 | * "bar baz boz" |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | public function getContent() |
||
89 | |||
90 | /** |
||
91 | * Convert tag back into a string. |
||
92 | */ |
||
93 | public function __toString() |
||
97 | |||
98 | /** |
||
99 | * Determine if tag is one of: |
||
100 | * - "@tag variable description" |
||
101 | * - "@tag $variable description" |
||
102 | * - "@tag type $variable description" |
||
103 | * |
||
104 | * @param string $subject |
||
|
|||
105 | * @param string[] &$matches Sets $matches['variable'] and |
||
106 | * $matches['description']; might set $matches['type']. |
||
107 | * @return bool |
||
108 | */ |
||
109 | public function hasVariable(&$matches) |
||
115 | |||
116 | /** |
||
117 | * Determine if tag is "@tag $variable description" |
||
118 | * @param string $subject |
||
119 | * @param string[] &$matches Sets $matches['variable'] and |
||
120 | * $matches['description'] |
||
121 | * @return bool |
||
122 | */ |
||
123 | public function hasVariableAndDescription(&$matches) |
||
128 | |||
129 | /** |
||
130 | * Determine if tag is "@tag type $variable description" |
||
131 | * |
||
132 | * @param string $subject |
||
133 | * @param string[] &$matches Sets $matches['variable'], |
||
134 | * $matches['description'] and $matches['type']. |
||
135 | * @return bool |
||
136 | */ |
||
137 | public function hasTypeVariableAndDescription(&$matches) |
||
142 | |||
143 | /** |
||
144 | * Determine if tag is "@tag word description" |
||
145 | * @param string $subject |
||
146 | * @param string[] &$matches Sets $matches['word'] and |
||
147 | * $matches['description'] |
||
148 | * @return bool |
||
149 | */ |
||
150 | public function hasWordAndDescription(&$matches) |
||
155 | } |
||
156 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.