Commit c3ffa574 authored by Klaus Purer's avatar Klaus Purer
Browse files

fix(FunctionComment): Methods named after the class should not throw return...

fix(FunctionComment): Methods named after the class should not throw return tag errors (#3013953 by klausi, Kingdutch)
parent 9dc15a30
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -369,12 +369,6 @@ class FunctionCommentSniff implements Sniff
                    }
                }//end if
            }//end if
        } else {
            // No return tag for constructor and destructor.
            if ($return !== null) {
                $error = '@return tag is not required for constructor and destructor';
                $phpcsFile->addError($error, $return, 'ReturnNotRequired');
            }
        }//end if

    }//end processReturn()
+22 −0
Original line number Diff line number Diff line
@@ -465,3 +465,25 @@ function test35(\stdClass $name, \stdClass $param2) {
function test36(object $arg, object $blarg) {
  return $arg;
}

/**
 * A class with a method that has the same name as the class.
 */
class Small {

  /**
   * Our small constructor.
   */
  public function __construct() {
  }

  /**
   * Return tag should be allowed here.
   *
   * @return string
   */
  public function small() {
    return 'string';
  }

}
+22 −0
Original line number Diff line number Diff line
@@ -491,3 +491,25 @@ function test35(\stdClass $name, \stdClass $param2) {
function test36(object $arg, object $blarg) {
  return $arg;
}

/**
 * A class with a method that has the same name as the class.
 */
class Small {

  /**
   * Our small constructor.
   */
  public function __construct() {
  }

  /**
   * Return tag should be allowed here.
   *
   * @return string
   */
  public function small() {
    return 'string';
  }

}