I wrote a test for a singleton class which tests the following:
Class method:
public static function getInstance(): SomeSingleton {
if (null === static::$instance) {
static::$instance = new static();
}
return static::$instance;
}
Test method:
public function testGetInstance(): void {
self::assertSame(SomeSingleton::getInstance(), SomeSingleton::getInstance());
}
With this code I could understand the error from occurring but when I changed the code in the singleton to this:
public static function getInstance(): SomeSingleton {
return new static();
}
The error still occurred even while the assertSame was now evaluating to false.