| 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.