I have such as Testcase:
class GenerateTest extends AbstractTestCase
{
private int $requestTime = 0;
...
protected function setUp(): void
{
$this->requestTime = $_SERVER['REQUEST_TIME']; // this is not null, verified by var_dump()
parent::setUp();
}
protected function tearDown(): void
{
parent::tearDown();
$_SERVER['REQUEST_TIME'] = $this->requestTime;
}
I am getting the error
Cannot assign null to property GenerateTest::$requestTime of type int"
without a line number.
Even if I comment the lines in setup/teardown, I get the error. In the class are no further assignments to requestTime
.
Where does this come from?
If i use ?int
it works, but I want to understand the root cause.
Does PHPUnit “automagically” reset class variables?