Skip to content

Commit

Permalink
Fixed callable types parsing (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
chack1172 authored Dec 30, 2024
1 parent 818be8d commit ffb733e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Barryvdh/Reflection/DocBlock/Type/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ protected function expand($type)
return $type;
}

// Check for callable types
if (preg_match('/\(.*?(?=\:)/', $type)) {
return $type;
}

if($type[0] === '(') {
return $type;
}
Expand Down
8 changes: 8 additions & 0 deletions tests/Barryvdh/Reflection/DocBlock/Type/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ public function provideTypesToExpand($method, $namespace = '\My\Space\\')
'iterable<string>',
array('iterable<string>')
),
array(
'callable',
array('callable')
),
array(
'callable(int, string): int',
array('callable(int, string): int')
)
);
}

Expand Down

0 comments on commit ffb733e

Please sign in to comment.