@@ -29,20 +29,22 @@ public function enterNode(Node $node)
29
29
parent ::enterNode ($ node );
30
30
31
31
if (!($ node instanceof Function_) && !($ node instanceof ClassMethod)) {
32
- return ;
32
+ return null ;
33
33
}
34
34
35
35
$ docComment = $ node ->getDocComment ();
36
36
37
37
if (!($ docComment instanceof Doc)) {
38
- return ;
38
+ return null ;
39
39
}
40
40
41
41
$ newDocComment = $ this ->addArrayHashNotation ($ docComment );
42
42
43
43
if ($ newDocComment !== null ) {
44
44
$ node ->setDocComment ($ newDocComment );
45
45
}
46
+
47
+ return null ;
46
48
}
47
49
48
50
private function addArrayHashNotation (Doc $ docComment ): ?Doc
@@ -168,6 +170,10 @@ private function getTypeNameFromType(Type $tagVariableType): ?string
168
170
// typed arrays such as `int[]` with `array`.
169
171
$ tagVariableType = preg_replace ('#[a-zA-Z0-9_]+\[\]# ' , 'array ' , $ tagVariableType ->__toString ());
170
172
173
+ if ($ tagVariableType === null ) {
174
+ return null ;
175
+ }
176
+
171
177
if (strpos ($ tagVariableType , 'array ' ) === false ) {
172
178
// Skip if we have hash notation that's not for an array (ie. for `object`).
173
179
return null ;
@@ -196,11 +202,22 @@ private function getElementsFromDescription(Description $tagDescription, bool $o
196
202
197
203
// Populate `$types` with the value of each top level `@type`.
198
204
$ types = preg_split ('/\R+ @type / ' , $ text );
205
+
206
+ if (!$ types ) {
207
+ return null ;
208
+ }
209
+
199
210
unset($ types [0 ]);
200
211
$ elements = [];
201
212
202
213
foreach ($ types as $ typeTag ) {
203
- list ($ type , $ name ) = preg_split ('#\s+# ' , trim ($ typeTag ));
214
+ $ parts = preg_split ('#\s+# ' , trim ($ typeTag ));
215
+
216
+ if (!$ parts || count ($ parts ) < 2 ) {
217
+ return null ;
218
+ }
219
+
220
+ list ($ type , $ name ) = $ parts ;
204
221
205
222
// Bail out completely if any element doesn't have a static key.
206
223
if (strpos ($ name , '...$ ' ) !== false ) {
0 commit comments