Skip to content

Commit 497e867

Browse files
authored
Merge pull request #116 from aternosorg/class-file-version-int
Change type to int for `classFileVersion` in UnsupportedClassVersionProblem
2 parents 1538bd5 + 2d88619 commit 497e867

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/Analysis/Problem/Bukkit/UnsupportedClassVersionProblem.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@
77

88
class UnsupportedClassVersionProblem extends PluginFileProblem
99
{
10-
protected ?string $classFileVersion = null;
10+
protected ?int $classFileVersion = null;
1111

1212
/**
13-
* @return string|null
13+
* @return int|null
1414
*/
15-
public function getJavaVersion(): ?string
15+
public function getJavaVersion(): ?int
1616
{
17-
return (int)$this->classFileVersion - 44;
17+
if ($this->classFileVersion === null) {
18+
return null;
19+
}
20+
21+
return $this->classFileVersion - 44;
1822
}
1923

2024
/**
@@ -41,7 +45,10 @@ public function setMatches(array $matches, mixed $patternKey): void
4145
{
4246
parent::setMatches($matches, $patternKey);
4347

44-
$this->classFileVersion = $matches[3];
48+
if ($matches[3] && is_numeric($matches[3])) {
49+
$this->classFileVersion = intval($matches[3]);
50+
}
51+
4552
$this->addSolution((new UpdateJavaSolution())->setVersion($this->getJavaVersion()));
4653
}
4754

0 commit comments

Comments
 (0)