I'm following a tutorial about TDD in symfony, the tutorial is reusing the same client in every request, and he does the following way:
private static ?KernelBrowser $client = null;
public function setUp(): void
{
parent::setUp();
if(self::$client === null){
self::$client = static::createClient();
}
}
The question is why is he using a private and static property and not a simple one.
Why is not possible to do this way?
private ?KernelBrowser $client = null;
public function setUp(): void
{
parent::setUp();
if($this->client === null){
$this->client = static::createClient();
}
}
I tried the second one and I get one new instance of client every time