Skip to content

Phpstan should not merge inherited @throw tag #3350

@VincentLanglet

Description

@VincentLanglet

When writing

class A {
  /**
   * @throws \LogicException
   *
   * @return void
   **/
  public method foo()
  {
    throw \LogicException();
  }
}

class B extends A {
  /**
   * @return void
   **/
  public method foo()
  {
    return;
  }
}

Phpstan is now merging the phpdoc and think that B::foo is returning an exception which is not true.

This has multiple bad effects on https://packagist.org/packages/pepakriz/phpstan-exception-rules
since it now report false positive Unused exception or You didn't try/catch a possible exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions