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

inconsistent @throws in Functions.php #3310

Closed
FyiurAmron opened this issue Sep 21, 2018 · 0 comments
Closed

inconsistent @throws in Functions.php #3310

FyiurAmron opened this issue Sep 21, 2018 · 0 comments

Comments

@FyiurAmron
Copy link

FyiurAmron commented Sep 21, 2018

Q A
PHPUnit version edge
PHP version any
Installation Method any

CURRENT BEHAVIOUR
As it currently stands, while Assert.php has both valid and informative @throws docs, Functions.php has some legacy (and absurd) - e.g. assertContains is currently declared as:

Functions.php

/**
 * Asserts that a haystack contains a needle.
 *
 * @throws Exception
 * @throws ExpectationFailedException
 * @throws \PHPUnit\Framework\Exception
 * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
 */
{
    Assert::assertContains(...\func_get_args());
}

Assert.php

    /**
     * Asserts that a haystack contains a needle.
     *
     * @throws ExpectationFailedException
     * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
     */
// ... actual code

RATIONALE FOR CHANGE
This makes maintaining tests which use the function form extremely tedious, since IDEs generally bitch about uncaught exceptions, especially with @throws Exception.

EXPECTED BEHAVIOUR
tl;dr because Functions.php is only a wrapper, functions in it should have exactly same @throws as corresponding methods from Assert.php

POSSIBLE ISSUES WITH FIXING
None that I am aware of.

POSSIBLE WORKAROUNDS
Either not using functions, or suppressing the IDE warnings about uncaught exceptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant