PhpFunctionUtil.getReturnType(): advanced analysis
rentalhost opened this issue · 0 comments
rentalhost commented
Additional analysis (should check if all is applicable):
- Compound types:
array
,,object
callable
(anditerable
?); - Resource type:
resource
; - Callable type:
callable
; - Void type:
void
;- From
return;
; - From no
return
statement;
- From
- Make sure to ignores unreacheable
return
statements;- After the last
return
(eg.return; return $unreacheable;
); - After an uncatched
throw
;
- After the last
- Support to complex array types:
- Return
int[]
from one type array (eg.[1, 2, 3]
); - Return
mixed[]
from mixed type array (eg.[1, 'a', true]
);
- Return
- Make sure that comparison returns
bool
(eg.return $a === $b
); - Make sure that expressions returns
int
(eg.return $a + $b
); - Make sure that concats returns
string
(eg.return $a . $b
);