Skip to content

Commit 6553dd3

Browse files
authored
introduce phpstan (#11)
* introduce phpstan * clear test cache
1 parent 045bd50 commit 6553dd3

File tree

7 files changed

+326
-44
lines changed

7 files changed

+326
-44
lines changed

composer.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
"symfony/browser-kit": "^6.4",
2828
"symfony/framework-bundle": "^6.4",
2929
"symfony/http-kernel": "^6.4",
30-
"symfony/stopwatch": "^6.4"
30+
"symfony/stopwatch": "^6.4",
31+
"phpstan/phpstan": "^1.11",
32+
"phpstan/phpstan-symfony": "^1.4",
33+
"symfony/runtime": "^6.4"
3134
},
3235
"autoload": {
3336
"psr-4": {
@@ -43,6 +46,8 @@
4346
"ci": [
4447
"composer validate",
4548
"@check-cs",
49+
"tests/Symfony/console ca:cl -e test",
50+
"@phpstan",
4651
"@phpunit"
4752
],
4853
"check-cs": [
@@ -53,11 +58,17 @@
5358
],
5459
"phpunit": [
5560
"phpunit"
61+
],
62+
"phpstan": [
63+
"phpstan analyse -c phpstan.neon"
5664
]
5765
},
5866
"config": {
5967
"platform": {
6068
"php": "8.1"
69+
},
70+
"allow-plugins": {
71+
"symfony/runtime": true
6172
}
6273
}
6374
}

composer.lock

Lines changed: 210 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
includes:
2+
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
3+
- vendor/phpstan/phpstan-symfony/extension.neon
4+
- vendor/phpstan/phpstan-symfony/rules.neon
5+
6+
parameters:
7+
phpVersion: 80100
8+
level: max
9+
paths:
10+
- src
11+
- tests
12+
symfony:
13+
containerXmlPath: var/cache/test/Chaos_Monkey_Symfony_Tests_Symfony_KernelTestDebugContainer.xml

src/DependencyInjection/ChaosMonkeyExtension.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,42 @@
99
use Symfony\Component\DependencyInjection\Extension\Extension;
1010
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
1111

12+
/**
13+
* @phpstan-type ConfigArray array{
14+
* enabled: bool,
15+
* probability: int,
16+
* assaults: array{
17+
* latency: array{active: bool, minimum: int, maximum: int},
18+
* memory: array{active: bool, fill_fraction: float},
19+
* exception: array{active: bool, class: class-string<\Throwable>},
20+
* kill_app: array{active: bool}
21+
* },
22+
* watchers: array{
23+
* request: array{enabled: bool, priority: int}
24+
* }
25+
* }
26+
*/
1227
class ChaosMonkeyExtension extends Extension
1328
{
14-
public function load(array $configs, ContainerBuilder $container)
29+
/**
30+
* @param array<array<mixed>> $configs
31+
*/
32+
public function load(array $configs, ContainerBuilder $container): void
1533
{
1634
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
1735
$loader->load('services.xml');
1836

1937
$configuration = new Configuration();
38+
/** @var ConfigArray $config */
2039
$config = $this->processConfiguration($configuration, $configs);
2140

2241
$this->setChaosMonkeySettings($container, $config);
2342
$this->enableWatchers($container, $config);
2443
}
2544

45+
/**
46+
* @param ConfigArray $config
47+
*/
2648
private function setChaosMonkeySettings(ContainerBuilder $container, array $config): void
2749
{
2850
$definition = $container->getDefinition('chaos_monkey.settings');
@@ -42,6 +64,9 @@ private function setChaosMonkeySettings(ContainerBuilder $container, array $conf
4264
$definition->addMethodCall('setKillAppActive', [$config['assaults']['kill_app']['active']]);
4365
}
4466

67+
/**
68+
* @param ConfigArray $config
69+
*/
4570
private function enableWatchers(ContainerBuilder $container, array $config): void
4671
{
4772
if ($config['watchers']['request']['enabled'] === true) {

0 commit comments

Comments
 (0)