aik099 / CodingStandard

The PHP_CodeSniffer coding standard I'm using on all of my projects
BSD 3-Clause "New" or "Revised" License
5 stars 2 forks source link

Improve comment detection before "return" statement #68

Open aik099 opened 9 years ago

aik099 commented 9 years ago

Case 1: block comments

else {
    /*if ( is_null($input_type)
        || ($input_type == self::TEXT_INPUT)
        || ($input_type == self::PASSWORD_INPUT)
    ) {*/
    return TextInput::fromNodeElement($node_element);
}

Case 2: multiple single line comments (just use https://github.com/aik099/CodingStandard/blob/master/CodingStandard/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php#L408)

else {
    // line 1
    // line 2
    return TextInput::fromNodeElement($node_element);
}

Case 3: comment belonging to other code (need to ignore such comment and don't combine it with return)

$var_name = new ClassName();
/** @var ClassName $var_name */

return $var_name;