Skip to content

Commit ffb733e

Browse files
authored
Fixed callable types parsing (#26)
1 parent 818be8d commit ffb733e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Barryvdh/Reflection/DocBlock/Type/Collection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ protected function expand($type)
205205
return $type;
206206
}
207207

208+
// Check for callable types
209+
if (preg_match('/\(.*?(?=\:)/', $type)) {
210+
return $type;
211+
}
212+
208213
if($type[0] === '(') {
209214
return $type;
210215
}

tests/Barryvdh/Reflection/DocBlock/Type/CollectionTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@ public function provideTypesToExpand($method, $namespace = '\My\Space\\')
283283
'iterable<string>',
284284
array('iterable<string>')
285285
),
286+
array(
287+
'callable',
288+
array('callable')
289+
),
290+
array(
291+
'callable(int, string): int',
292+
array('callable(int, string): int')
293+
)
286294
);
287295
}
288296

0 commit comments

Comments
 (0)