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

Proposed Fix of Return value of PHPUnit\Framework\TestCase::getExpectedExceptionMessage() must be of the type string, null returned #3480

Closed
slaughter550 opened this issue Jan 14, 2019 · 1 comment

Comments

@slaughter550
Copy link
Contributor

slaughter550 commented Jan 14, 2019

Q A
PHPUnit version 7.5.1
PHP version 7.2.11
Installation Method Composer

In https://github.com/sebastianbergmann/phpunit/blob/7.5/src/Framework/TestCase.php, there are the following variable declarations

    /**
     * @var null|string
     */
    private $expectedException;

    /**
     * @var string
     */
    private $expectedExceptionMessage;

    /**
     * @var string
     */
    private $expectedExceptionMessageRegExp;

and the following getters

    public function getExpectedException(): ?string
    {
        return $this->expectedException;
    }

    public function getExpectedExceptionMessage(): string
    {
        return $this->expectedExceptionMessage;
    }

    public function getExpectedExceptionMessageRegExp(): string
    {
        return $this->expectedExceptionMessageRegExp;
    }

Due to the fact that both expectedExceptionMessage and expectedExceptionMessageRegExp are declared but not initialized on instantiation, there is a chance that when called, they violate their requirement to return a string.

Proposed solution. Make them optionally return a string just like expectedException allows for.

@sebastianbergmann thoughts? I'm happy to produce the PR if you are good with this direction.

@slaughter550 slaughter550 changed the title Return value of PHPUnit\Framework\TestCase::getExpectedExceptionMessage() must be of the type string, null returned Proposed Fix of Return value of PHPUnit\Framework\TestCase::getExpectedExceptionMessage() must be of the type string, null returned Jan 14, 2019
@slaughter550
Copy link
Contributor Author

@sebastianbergmann ping

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