Skip to content

Commit 3f952b3

Browse files
committed
Phpstan: fix lvl 9
1 parent 83879e3 commit 3f952b3

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/Module/NetteApplicationModule.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,21 @@
1515
class NetteApplicationModule extends Framework
1616
{
1717

18+
/** @var array<string, mixed> */
1819
protected array $config = [
1920
'followRedirects' => true,
2021
];
2122

22-
/** @var string */
23-
private $path;
23+
private string $path;
2424

2525
/**
26-
* @param mixed[] $settings
26+
* @param array{path?: string} $settings
2727
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
2828
*/
2929
public function _beforeSuite($settings = []): void
3030
{
31+
assert(isset($settings['path']));
32+
3133
$this->path = $settings['path'];
3234
}
3335

@@ -42,7 +44,7 @@ function (): Container {
4244
return $diModule->getContainer();
4345
}
4446
);
45-
$this->client->followRedirects($this->config['followRedirects']);
47+
$this->client->followRedirects((bool) $this->config['followRedirects']);
4648

4749
parent::_before($test);
4850
}

src/Module/NetteDIModule.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Codeception\Module;
66
use Codeception\TestInterface;
7-
use Nette\Caching\Storages\IJournal;
7+
use Nette\Caching\Storages\Journal;
88
use Nette\Caching\Storages\SQLiteJournal;
99
use Nette\Configurator;
1010
use Nette\DI\Container;
@@ -23,6 +23,7 @@ class NetteDIModule extends Module
2323
/** @var callable[] function(Container $container): void; */
2424
public $onCreateContainer = [];
2525

26+
/** @var array<string, mixed> */
2627
protected array $config = [
2728
'configFiles' => [],
2829
'appDir' => null,
@@ -33,6 +34,7 @@ class NetteDIModule extends Module
3334
'newContainerForEachTest' => false,
3435
];
3536

37+
/** @var string[] */
3638
protected array $requiredFields = [
3739
'tempDir',
3840
];
@@ -47,11 +49,13 @@ class NetteDIModule extends Module
4749
private $container;
4850

4951
/**
50-
* @param mixed[] $settings
52+
* @param array{path?: string} $settings
5153
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
5254
*/
53-
public function _beforeSuite($settings = []): void
55+
public function _beforeSuite(array $settings = []): void
5456
{
57+
assert(isset($settings['path']));
58+
5559
$this->path = rtrim($settings['path'], '/');
5660
$this->clearTempDir();
5761
}
@@ -141,9 +145,10 @@ private function createContainer(): void
141145
$configurator->setTempDirectory($tempDir);
142146

143147
if ($this->config['debugMode'] !== null) {
144-
$configurator->setDebugMode($this->config['debugMode']);
148+
$configurator->setDebugMode((bool) $this->config['debugMode']);
145149
}
146150

151+
/** @var iterable<string> $configFiles */
147152
$configFiles = $this->configFiles !== [] ? $this->configFiles : $this->config['configFiles'];
148153
foreach ($configFiles as $file) {
149154
$configurator->addConfig(FileSystem::isAbsolute($file) ? $file : $this->path . '/' . $file);
@@ -198,7 +203,7 @@ private function stopContainer(): void
198203
}
199204

200205
try {
201-
$journal = $this->container->getByType(IJournal::class);
206+
$journal = $this->container->getByType(Journal::class);
202207
if ($journal instanceof SQLiteJournal) {
203208
$property = new ReflectionProperty(SQLiteJournal::class, 'pdo');
204209
$property->setAccessible(true);

0 commit comments

Comments
 (0)