Bad code can contains one return with a value and one without a value:
/** * @param string $arg1 * @return string */ public function funcTest( $arg1 ) { if ( $arg1 === '' ) { return 'none'; } return; }
Such code can surprise the caller by getting a void and may break.
A sniff should check if all return are void or non-void inside the code.
Return inside closures or inner functions could make this a bit harder to check for.
Ignore return in __construct