Skip to content

Commit 49a480f

Browse files
author
Chris Bell
committed
Add optional return types for PHP 7.
1 parent fd52cd8 commit 49a480f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

jsdocs.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,13 +772,15 @@ def parseFunction(self, line):
772772
+ '(?P<name>' + self.settings['fnIdentifier'] + ')'
773773
# function fnName
774774
# (arg1, arg2)
775-
+ '\\s*\\(\\s*(?P<args>.*)\\)',
775+
+ '\\s*\\(\\s*(?P<args>.*)\\)'
776+
# optional return type
777+
+ '(\\s*?:\\s*(?P<retval>' + self.settings['typeIdentifier'] + '))?',
776778
line
777779
)
778780
if not res:
779781
return None
780782

781-
return (res.group('name'), res.group('args'), None)
783+
return (res.group('name'), res.group('args'), res.group('retval'))
782784

783785
def getArgType(self, arg):
784786

@@ -873,6 +875,10 @@ def getFunctionReturnType(self, name, retval):
873875
return 'string'
874876
if name == '__isset':
875877
return 'bool' if shortPrimitives else 'boolean'
878+
879+
if (retval):
880+
return retval
881+
876882
return JsdocsParser.getFunctionReturnType(self, name, retval)
877883

878884

0 commit comments

Comments
 (0)