Skip to content

Commit 4cf9e7f

Browse files
PHPStan level 9 (and final) compatibility.
1 parent 23c6153 commit 4cf9e7f

File tree

6 files changed

+13
-11
lines changed

6 files changed

+13
-11
lines changed

phpstan.neon

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
parameters:
2-
level: 8
2+
level: 9
33
checkMissingIterableValueType: false
44
checkGenericClassInNonGenericObjectType: false
55
doctrine:
66
objectManagerLoader: tests/object-manager.php
77
universalObjectCratesClasses:
88
- RPGFaker\RPGFaker
99
paths:
10-
- src
10+
- src
11+
ignoreErrors:
12+
- '#. but returns mixed.#'

src/Model/Creature/AbstractCreature.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public function __construct()
4343
$nameFaker = new RPGFaker(['count' => 1]);
4444
$this->faker = FakerFactory::create('ja_JP');
4545
$this->loot = new InventoryBag();
46-
$this->rawName = $nameFaker->name;
46+
if (is_string($generatedName = $nameFaker->name)) {
47+
$this->rawName = $generatedName;
48+
}
4749
}
4850

4951
public function getExperience(): int

src/Repository/LeaderboardRepository.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ public function __construct(ManagerRegistry $registry)
1919
parent::__construct($registry, Leaderboard::class);
2020
}
2121

22-
/**
23-
* @return array|Leaderboard[]
24-
*/
2522
public function getBest(): array
2623
{
2724
$query = $this->createQueryBuilder('l')

src/Service/LeaderboardService.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ public function __construct(LeaderboardRepository $leaderboardRepository, Entity
2020
$this->em = $em;
2121
}
2222

23-
/**
24-
* @return Leaderboard[]|array
25-
*/
2623
public function getBestScores(): array
2724
{
2825
try {

src/Service/PlayerService.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ class PlayerService
1515
public function __construct()
1616
{
1717
$rpgFaker = new RPGFaker(['count' => 1, 'race' => 'human']);
18-
$this->player = new Player($rpgFaker->name, new PlayerCoordinates(0, 0));
18+
if (is_string($generatedName = $rpgFaker->name)) {
19+
$this->player = new Player($generatedName, new PlayerCoordinates(0, 0));
20+
} else {
21+
throw new \LogicException('Initialization of Player failed due to bug in name generator.');
22+
}
1923
}
2024

2125
public function getPlayer(): PlayerInterface

src/Service/YamlLevelParserService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected function processCurrentYamlFile(): void
2121
throw new Exception('Not file specified');
2222
}
2323

24-
$this->yamlProcessed = Yaml::parseFile($this->yamlFilePath);
24+
$this->yamlProcessed = (array) Yaml::parseFile($this->yamlFilePath);
2525
}
2626

2727
public function setYamlFilePath(string $yamlFilePath): void

0 commit comments

Comments
 (0)