Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot suppress InvalidReturnType for never-returns #2349

Closed
TysonAndre opened this issue Nov 14, 2019 · 1 comment
Closed

Cannot suppress InvalidReturnType for never-returns #2349

TysonAndre opened this issue Nov 14, 2019 · 1 comment
Labels

Comments

@TysonAndre
Copy link
Contributor

Expected: Should have a way to suppress it if you could guarantee that the arguments/global state would ensure the function always returns (e.g. print_help(bool $exit))
Observed: psalm-suppress does not take effect

<?php

function may_exit() : void {
    exit(0);
}

/**
 * @psalm-suppress InvalidReturnType this suppression is not taking effect
 * @psalm-return never-returns
 */
function test() {
    may_exit();
}

https://psalm.dev/r/5d43404836

@muglug muglug closed this as completed in b3a15e8 Nov 14, 2019
@TysonAndre
Copy link
Contributor Author

<?php

function may_exit() : void {
    exit(0);
}

class InClass {
  /**
   * @psalm-suppress InvalidReturnType this suppression is not taking effect
   * @psalm-return never-returns
   */
  function test() {
      may_exit();
  }
}

For whatever reason, it still occurs on methods (but is fixed for global functions). Are the suppressions added after return types get analyzed?

https://psalm.dev/r/d0eae0e694

@muglug muglug added the bug label Nov 15, 2019
@muglug muglug reopened this Nov 15, 2019
@muglug muglug closed this as completed in d7fb64b Dec 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants