Skip to content

Commit bc1b787

Browse files
committed
Update PHPUnitVersionDetector.php
1 parent fba806d commit bc1b787

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Rules/PHPUnit/PHPUnitVersionDetector.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
class PHPUnitVersionDetector
1414
{
1515

16+
private bool $initialized = false;
17+
1618
private ?int $majorVersion = null;
1719

1820
private ReflectionProvider $reflectionProvider;
@@ -24,16 +26,17 @@ public function __construct(ReflectionProvider $reflectionProvider)
2426

2527
public function isPHPUnit10OrNewer(): bool
2628
{
27-
return $this->getMajorVersion() >= 10;
29+
$majorVersion = $this->getMajorVersion();
30+
return $majorVersion !== null && $majorVersion >= 10;
2831
}
2932

30-
private function getMajorVersion(): int
33+
private function getMajorVersion(): ?int
3134
{
32-
if ($this->majorVersion !== null) {
35+
if ($this->initialized) {
3336
return $this->majorVersion;
3437
}
38+
$this->initialized = true;
3539

36-
$this->majorVersion = 9;
3740
if ($this->reflectionProvider->hasClass(TestCase::class)) {
3841
$testCase = $this->reflectionProvider->getClass(TestCase::class);
3942
$file = $testCase->getFileName();

0 commit comments

Comments
 (0)